Computing.Net > Forums > Unix > Write to 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.

Write to file

Reply to Message Icon

Name: Diaz
Date: February 11, 2002 at 21:26:12 Pacific
Comment:

Hello i'm still new of using unix shell commands
i'm gonna build a simple shell script that write to some file like "logs.txt" everytime the script is executed.
the string that is going to be written to the file is static like "Succeed written to logs.txt"

how can i manage the write to file script ?
thanks



Sponsored Link
Ads by Google

Response Number 1
Name: kendel
Date: February 12, 2002 at 05:17:54 Pacific
Reply:

hi diaz,

try to redirect output to your logfile

write command > logs.txt
k


0

Response Number 2
Name: James Boothe
Date: February 12, 2002 at 06:07:21 Pacific
Reply:

The echo or print command is typical used for that, and as kendel states, redirect the output of the command to your file. The first command below will overwrite any existing file and start a new file, while the second command will either start a new file (if no file already) or will append to an existing file:

echo `date` Success > logs.txt
echo `date` Success >> logs.txt


0

Sponsored Link
Ads by Google
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: Write to file

writing to Log files www.computing.net/answers/unix/writing-to-log-files/6124.html

Writeing to a profile www.computing.net/answers/unix/writeing-to-a-profile/5400.html

Writing to/reading from 3, 4 etc. www.computing.net/answers/unix/writing-toreading-from-3-4-etc/7388.html