slicing the date

Jean-Pierre Radley jpr at dasys1.UUCP
Sat Apr 1 13:21:16 AEST 1989


In article <216000010 at s.cs.uiuc.edu> carroll at s.cs.uiuc.edu writes:
>Allright, I can't figure this out. I'm trying to put the current system
>time in my prompt. Under SysV, I can use 'cut' to pick out the seperate
>hours, minutes, and seconds from 'date'. For non-SysV types, 'cut' lets
>you pick out fields using either delimiter characters or absolute column
>counts. I found a way to do this using Ksh (with the pattern matchers),
>but it is very ugly. The question is, how can I cut up the output of
>date to put the hours, minutes, and seconds into seperate variables? Thanks!

Using 'cut'? Why? Why not just pick a format from the repertoire of the
'date' command, then use the /bin/sh built-in "set" to extract variables?


set `date "+%H %M %S"` ; echo $1 $2 $3

Or maybe you want 

TIME = `date "+%H:%M:%S"`

-- 
Jean-Pierre Radley		Honi soit		jpr at dasys1.UUCP
New York, New York		qui mal			...!hombre!jpradley!jpr
CIS: 76120,1341			y pense			...!hombre!trigere!jpr



More information about the Comp.unix.questions mailing list