Computing.Net > Forums > Unix > Shell output file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Shell output file

Reply to Message Icon

Name: mlawton40
Date: January 29, 2009 at 03:20:53 Pacific
OS: Windows XP
CPU/Ram: 1.18GHz/2GB RAM
Product: Intel / CORE 2 DUO
Subcategory: General
Comment:

Hi,

I'm creating a shell script and have the following example of what I'm trying to do:

if ps -ef | egrep -v egrep | egrep -q example
then echo example OK
else echo example IS NOT RUNNING
fi

if ps -ef | egrep -v egrep | egrep -q example2
then echo example2 OK
else echo example2 IS NOT RUNNING
fi

I want the output (e.g example ok) then on the next line (e.g example2 ok) in a file e.g. outcome.log/txt instead of it being printed on the screen.

Thanks.



Sponsored Link
Ads by Google

Response Number 1
Name: James Boothe
Date: January 29, 2009 at 15:31:14 Pacific
Reply:

To redirect your echo to a file:

echo something > myfile

Also, output can be sent to the screen AND to a file at the same time:

echo something | tee myfile

The above command would replace any existing file. More commonly, you would append to the file:

echo something | tee -a myfile


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Shell output file

Need help creating an output files www.computing.net/answers/unix/need-help-creating-an-output-files/7902.html

backup a file with SHELL SCRIPT www.computing.net/answers/unix/backup-a-file-with-shell-script/4522.html

Shell script to find files www.computing.net/answers/unix/shell-script-to-find-files/5440.html