Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!eecae!netnews.upenn.edu!rutgers!att!ncsc1!dgp From: dgp@ncsc1.AT&T.NCSC (Dennis Pelton CSM Contractor x8876) Newsgroups: comp.unix.questions Subject: Re: slicing the date Message-ID: <431@ncsc1.AT&T.NCSC> Date: 29 Mar 89 15:57:14 GMT References: <216000010@s.cs.uiuc.edu> Organization: AT&T NCSC, Englewood,CO Lines: 32 In article <216000010@s.cs.uiuc.edu>, carroll@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! > > Alan M. Carroll "And then you say, > carroll@s.cs.uiuc.edu We have the Moon, so now the Stars..." - YES > CS Grad / U of Ill @ Urbana ...{ucbvax,pur-ee,convex}!s.cs.uiuc.edu!carroll OK, here's one way: hrs=`date +'%H'` min=`date +'%M'` sec=`date +'%S'` Andhere's another: date +'%H %M %S' >now read hrs min sec