slicing the date
Chuck Karish
karish at forel.stanford.edu
Wed Mar 29 14:47:33 AEST 1989
In article <216000010 at s.cs.uiuc.edu> carroll at s.cs.uiuc.edu wrote:
>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'.
Why bother using cut? The SysV date command lets you format
its output directly.
>The question is, how can I cut up the output of
>date to put the hours, minutes, and seconds into seperate variables? Thanks!
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]:..\):.*"
Chuck Karish hplabs!hpda!mindcrf!karish (415) 493-7277
karish at forel.stanford.edu
More information about the Comp.unix.questions
mailing list