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