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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some bash Tips

Status
Not open for further replies.

whegge

IS-IT--Management
Jan 2, 2002
40
0
0
US
I am using a bash script to copy files from my production server to a standby server, really just a simple backup. I have been trying to figure out how to do 2 things with bash.

1) How do I direct an echo statement out to a file? Logging what commands were run from the script.

2) How do I get a date and time from bash? I would like to date stamp the log file.

Thanks for everyones help,

Wes Hegge
 
To redirect output to a file

echo $text > file (this will create a new file and overwrite everytime ran)

echo $text >> file (appends the file)

so first echo creates file and second appends.


man date. The date command will give a standard output however you can customize the output
date +%Y%m%d = 20020411
you can also do things like this date +%Y/%m/%d to add slashes.
 
Thanks! I actually figured out the redirect with echo. Did not think of date though.

Wes
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top