Re: UNIX script

  • From: stephen booth <stephenbooth.uk@xxxxxxxxx>
  • To: sjaffarhussain@xxxxxxxxx
  • Date: Tue, 29 Mar 2005 13:55:12 +0100

On Tue, 29 Mar 2005 15:45:21 +0300, The Human Fly
<sjaffarhussain@xxxxxxxxx> wrote:
> Hello list,
> 
> Sorry, its slightly off-topic, UNIX related.
> 
> My requirement is whenever I divert my output to a file, that should
> contains filename along with the data and time.
> 
> For example,
> 
> ls -ltr > xyz
> 
> and next time when I do the same, it should ot overwite to the file,
> instead create the file with date and time along with it.

You need to use the date command:

# ls -ltr > xyz.`date [options]`

Note that ` is the backtick which causes the shell to execute what
they contain as a command and pipe the output back.

I can't remember the options off the top of my head.  Check the man
page for the date command.  As I recall 'xyz.`date +%Y%m%d`'  should,
today,  give you 'xyz.20050329' but test it first.

Stephen

-- 
It's better to ask a silly question than to make a silly assumption.
--
//www.freelists.org/webpage/oracle-l

Other related posts: