another way (was Re: slicing the date)

Randal L. Schwartz @ Stonehenge merlyn at intelob.intel.com
Fri Mar 31 05:41:44 AEST 1989


In article <1177 at Portia.Stanford.EDU>, karish at forel (Chuck Karish) writes:
| 	set `date | tr ':' ' '`
| 	hr=$4
| 	min=$5
| 	sec=$6
| 
| 	If that's not ugly enough for you, use this instead:
| 
| 	expr "`date`" \: ".*\([ 	0-9][0-9]:..\):.*"

For the truly ugly (and no additional processes), try:

oldIFS="$IFS" IFS=": "; set - `date`; hr=$4 min=$5 sec=$6 IFS="$oldIFS"

Amazing what /bin/sh can do for you if you let it. :-)
(I'm trying to write EMACS in /bin/sh... anyone want to help? :-)

Just another UNIX hacker,
-- 
/     Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095        \
|        on contract to BiiN (for now :-) Hillsboro, Oregon, USA.             |
|<@intel-iwarp.arpa:merlyn at intelob.intel.com> ...!uunet!tektronix!biin!merlyn |
\     Cute quote: "Welcome to Oregon... home of the California Raisins!"      /



More information about the Comp.unix.questions mailing list