Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unique File Name for use in script

Status
Not open for further replies.
Feb 14, 2000
425
US
I am putting togeather a script to pipe an applications log data out to a file and do not want to overwright the previous output, I remember once using some form of $pid or something like that to include the cmd's pid as part of my output filename. Don't have time to go back and try to find that script.

any help would be great!
Steve Bowman
steve.bowman@wayservices.com

 
"$$" is your current pid so file.$$ (or whatever) is a unique file name.

On most systems you also have the "mktemp" command

Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
I like to use the date command to create unique names, plus it keeps the file names in chronological order, for example:
cp logfile logfile`date =%y%m%d%T`
 
Sorry, that previous command should read
cp logfile logfile`date +%y%m%d%T`
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top