Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!shelby!Portia!forel!karish From: karish@forel.stanford.edu (Chuck Karish) Newsgroups: comp.unix.questions Subject: Re: slicing the date Message-ID: <1177@Portia.Stanford.EDU> Date: 29 Mar 89 04:47:33 GMT References: <216000010@s.cs.uiuc.edu> Sender: USENET News System Reply-To: karish@forel.stanford.edu (Chuck Karish) Organization: Mindcraft, Inc. Lines: 24 In article <216000010@s.cs.uiuc.edu> carroll@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@forel.stanford.edu