LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-11-2011, 07:08 AM   #1
sysmanz
LQ Newbie
 
Registered: Jul 2011
Posts: 21

Rep: Reputation: Disabled
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
 
Old 07-11-2011, 07:22 AM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
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)
./bash.sh > $LOGFILE
 
1 members found this post helpful.
Old 07-11-2011, 07:30 AM   #3
sysmanz
LQ Newbie
 
Registered: Jul 2011
Posts: 21

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by tredegar View Post
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)
./bash.sh > $LOGFILE
It works but the result is not what i want.
The logfile created and its contain :
Code:
Usage: ./domain-check [ -e email ] [ -x expir_days ] [ -q ] [ -a ] [ -h ]
          {[ -d domain_namee ]} || { -f domainfile}

  -a               : Send a warning message through email 
  -d domain        : Domain to analyze (interactive mode)
  -e email address : Email address to send expiration notices
  -f domain file   : File with a list of domains
  -h               : Print this screen
  -s whois server  : Whois sever to query for information
  -q               : Don't print anything on the console
  -x days          : Domain expiration interval (eg. if domain_date < days)
But the output is something like this and I need to see this result into logfile :
Code:
roghan@Nabati:~$ ./domain-check -d yahoo.com

Domain                              Registrar         Status   Expires     Days Left
----------------------------------- ----------------- -------- ----------- ---------
yahoo.com                           MARKMONITOR INC.  Valid    19-jan-2012   192
Sorry.. I'm newbie in this case..

Last edited by sysmanz; 07-11-2011 at 07:32 AM.
 
Old 07-11-2011, 07:33 AM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
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.
 
Old 07-11-2011, 07:41 AM   #5
sysmanz
LQ Newbie
 
Registered: Jul 2011
Posts: 21

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TobiSGD View Post
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.
I think I'm not.
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

Last edited by sysmanz; 07-11-2011 at 07:43 AM.
 
Old 07-11-2011, 08:26 AM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Did you try it like this:

Code:
logfile=logfile-$(date +%s)
./domain-check -d yahoo.com > $logfile
?
 
Old 07-11-2011, 08:26 AM   #7
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
Code:
./domain-check   -d   yahoo.com   >   logfile-$(date +%s)
Should do it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Sed – how do I save output to file with filename from content of another file? misarab Programming 4 02-28-2011 02:12 PM
Save output of libmemusage.so into a file Consystor Linux - Software 1 07-12-2009 04:29 AM
How can I save gcc output in a file ? techsavvy Linux - General 3 06-24-2008 07:38 AM
how to save output of 'fuser' to a file p_raju Linux - General 2 05-28-2008 10:50 AM
PHP: save output to a file mikeshn Programming 2 10-25-2003 06:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration