|
|
Making a log?
How do I make a log with the info given by this script?
Making a log?
How do I make a log with the info given by this script?
% ./scriptname > battery.log Puts the output of the script into the file, but how do I append new data to the end of the file and maybe add a timestamp? Can it be done in a single command or would it have to be build into the script itself?
This appends a timestamp and scriptname's output to a log file:
Shell Scripting
Don't wish to intrude but this will not work as expected The semi coloen is a command delimeter so the date command will have default input and output where as the other command will have output redirected to the log file. To accomplish what you wish you can do it two ways. (The first I belive may not be supported in every shell. % (date ; scriptname) >> logfile.log
or % date >> logfile.log ; scriptname >> logfile.log
Making a log?
you could do something like:
Making a log?
Ah yes. The "echo" can be safely omitted when using csh, though it won't hurt to have it in there. With bash, you have to include it or it won't work.
Making a log?
*sigh* nevermind. Don't omit the "echo". You'll need the entire command as I originally posted it, in both csh and bash. Otherwise, either you won't get the timestamp in the log file, or the shell will try to execute the resulting text. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.09 seconds |
|