home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / question / 9373 < prev    next >
Encoding:
Text File  |  1992-07-23  |  2.5 KB  |  67 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!mcsun!sunic!ericom!eos.ericsson.se!etxmesa
  3. From: etxmesa@eos.ericsson.se (Michael Salmon)
  4. Subject: Re: Redirecting the date as a file name
  5. Message-ID: <1992Jul24.073019.4230@ericsson.se>
  6. Keywords: redirection filenames date-to-filename
  7. Sender: news@ericsson.se
  8. Nntp-Posting-Host: eos6c02.ericsson.se
  9. Reply-To: etxmesa@eos.ericsson.se (Michael Salmon)
  10. Organization: Ericsson Telecom AB
  11. References:  <bacon.711843971@odin>
  12. Date: Fri, 24 Jul 1992 07:30:19 GMT
  13. Lines: 52
  14.  
  15. In article <bacon.711843971@odin>, bacon@odin.unomaha.edu (Melissa Bacon) writes:
  16. |> I'm setting up a .logout file that shows files that I have edited or
  17. |> added in the past day.  So far, so good.  This was no problem.  However,
  18. |> now what I want to do is to take the system date and tee my list of
  19. |> files to another file with the date (  date | cut -c5-10 ) as the
  20. |> filename.  How can I redirect the output of that command and use it to
  21. |> create a filename (for example, today's file should have the name
  22. |> 'Jul 22' ?  Is it possible to save the output as a string which then
  23. |> could be outputted as the filename?
  24.  
  25. From the man page for date:
  26.  
  27.      If the argument begins with +, the output of date  is  under
  28.      the control of the user.  The format for the output is simi-
  29.      lar to that of the first argument to printf(3V).  All output
  30.      fields  are  of fixed size (zero padded if necessary).  Each
  31.      field descriptor is preceded by % and will  be  replaced  in
  32.      the  output  by  its  corresponding  value.   A  single % is
  33.      encoded by %%.  All other characters are copied to the  out-
  34.      put  without change.  The string is always terminated with a
  35.      new-line character.
  36.  
  37.      Field Descriptors:
  38.           n    insert a new-line character
  39.           t    insert a tab character
  40.           m    month of year - 01 to 12
  41.           d    day of month - 01 to 31
  42.           y    last 2 digits of year - 00 to 99
  43.           D    date as mm/dd/yy
  44.           H    hour - 00 to 23
  45.           M    minute - 00 to 59
  46.           S    second - 00 to 59
  47.           T    time as HH:MM:SS
  48.           j    day of year - 001 to 366
  49.           w    day of week - Sunday = 0
  50.           a    abbreviated weekday - Sun to Sat
  51.           h    abbreviated month - Jan to Dec
  52.           r    time in AM/PM notation
  53.  
  54. Hence something like `date +NewFiles.%y.%j` will give you a unique file
  55. name over the next century. Customise according to taste.
  56.  
  57. -- 
  58.  
  59. Michael Salmon
  60.  
  61. #include    <standard.disclaimer>
  62. #include    <witty.saying>
  63. #include    <fancy.pseudo.graphics>
  64.  
  65. Ericsson Telecom AB
  66. Stockholm
  67.