Contents
How do you create a log file in Unix shell script?
To write output of Bash Command to Log File, you may use right angle bracket symbol (>) or double right angle symbol (>>). Right angle braketsymbol (>) : is used to write output of a bash command to a disk file. If the file is not already present, it creates one with the name specified.
How do I create a log file in Linux script?
The syntax is as follows for GNU/date:
- date +”FORMAT” …
- NOW=$(date +”%Y-%m-%d”) …
- NOW=$(date +”%F”) …
- LOGFILE=”log-$NOW.log” …
- echo “$LOGFILE”
5 февр. 2006 г.