Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!shadooby!eecae!netnews.upenn.edu!rutgers!att!mtuxo!mtgzz!drutx!druhi!rgreen From: rgreen@druhi.ATT.COM (Rodney R. Green) Newsgroups: comp.unix.questions Subject: Re: slicing the date Message-ID: <4099@druhi.ATT.COM> Date: 30 Mar 89 16:04:26 GMT References: <216000010@s.cs.uiuc.edu> Organization: AT&T, Denver, CO Lines: 30 in article <216000010@s.cs.uiuc.edu>, carroll@s.cs.uiuc.edu says: > Nf-ID: #N:s.cs.uiuc.edu:216000010:000:703 > Nf-From: s.cs.uiuc.edu!carroll Mar 27 15:34:00 1989 > > .... 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 The date command has a parameter with which you can specify the format of the output. The following three commands will output the hours, minutes, and seconds respectively: date +%H date +%M date +%S Of course, setting them separately can result in skew (suppose the hour changes between the time you set hours and minutes). You can get output of the form HH MM SS with the following command. date +"%H %M %S" and then cut it up to get the pieces you want. See the manual page for date(1) for the complete description of formatting from date. Rodney Green rgreen@druhi.att.com ...!att!druhi!rgreen AT&T Bell Laboratories Denver, CO