save output of bash file
Hi Guys,
I've shell bash file script and I want to save the output into a txt file. I Know ./bash.sh > output.txt will save the result into a file but i want to add something into a bash file and then when the bash file process completed, it save the result into a file and I don't want that overwrite the output into the old file, I want each time i run it, it save the result into a new file. How can i do that ?! Thanks |
You need to create a new filename each time you want the log saved.
You can easily do this with date date +%s gives the number of seconds since 1970-01-01 00:00:00 UTC Sample code: Code:
LOGFILE=logfile-$(date +%s) |
Quote:
The logfile created and its contain : Code:
Usage: ./domain-check [ -e email ] [ -x expir_days ] [ -q ] [ -a ] [ -h ] Code:
roghan@Nabati:~$ ./domain-check -d yahoo.com |
Then you have made a mistake with the options for your shell-script. Please post the exact command you used and also how you use the program when you don't create a logfile.
|
Quote:
Its the script url http://www.cyberciti.biz/files/scrip...in-check-2.txt And i use it like this ./domain-check -d yahoo.com I added the code tredegar gaves to me and it make the logfile itself but the result is not what i want. I want the shell script output into a file. Regards |
Did you try it like this:
Code:
logfile=logfile-$(date +%s) |
Code:
./domain-check -d yahoo.com > logfile-$(date +%s) |
All times are GMT -5. The time now is 04:24 PM. |