another way (was Re: slicing the date)

John Woods john at frog.UUCP
Tue Apr 4 09:43:00 AEST 1989


In article <4259 at omepd.UUCP>, merlyn at intelob.intel.com (Randal L. Schwartz @ Stonehenge) writes:
E> In article <1177 at Portia.Stanford.EDU>, karish at forel (Chuck Karish) writes:
l> | 	set `date | tr ':' ' '`
e> | 	hr=$4
g> | 	min=$5
a> | 	sec=$6
n> | 	If that's not ugly enough for you, use this instead:
c> | 	expr "`date`" \: ".*\([ 	0-9][0-9]:..\):.*"
e> For the truly ugly (and no additional processes), try:
.> oldIFS="$IFS" IFS=": "; set - `date`; hr=$4 min=$5 sec=$6 IFS="$oldIFS"

For the truly elegant (with no additional processes), scarf up the date.c
I just posted to comp.unix.questions and alt.sources (if you don't have
a System V date command), and try

	eval `date '+hr=%H min=%M sec=%S'`

-- 
John Woods, Charles River Data Systems, Framingham MA, (508) 626-1101
...!decvax!frog!john, john at frog.UUCP, ...!mit-eddie!jfw, jfw at eddie.mit.edu

			Remainder Khomeini!



More information about the Comp.unix.questions mailing list