- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Outputs to a file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 07:06 AM
06-11-2003 07:06 AM
Outputs to a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 07:08 AM
06-11-2003 07:08 AM
Re: Outputs to a file
somecommand > logfile
Which will overwrite every time.
What you should use is:
somecommand >> logfile
The >> is an append, so the next time you do a
someothercommand >> logfile
the output will be appended to the logfile.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 07:08 AM
06-11-2003 07:08 AM
Re: Outputs to a file
Have you tried using the '>>' operator for your redirection? The '>>' operator will append to a file while '>' will overwrite. You can do this:
ls >myfile
bdf >>myfile
date >>myfile
The first command overwrites the file and the following commands append to it.
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 07:09 AM
06-11-2003 07:09 AM
Re: Outputs to a file
You should use this symbol ">>" (without quotes) to append output to the same file which will keep the later output from overwriting the earlier output.
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 07:10 AM
06-11-2003 07:10 AM
Re: Outputs to a file
>> will append to, or create a file
> will create or overwrite a file
If thats not the case, include your script for our review.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 07:14 AM
06-11-2003 07:14 AM
Re: Outputs to a file
Use >> to write to a log file.
command >> command.log
This will append the output to the log file.
If you use only > you will overwrite the file.
Regards,
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 07:17 AM
06-11-2003 07:17 AM
Re: Outputs to a file
ie command | tee /tmp/file.out
this way you can keep screen output.
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 07:18 AM
06-11-2003 07:18 AM
Re: Outputs to a file
ie command | tee /tmp/file.out
this way you can keep screen output.
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 07:22 AM
06-11-2003 07:22 AM
Re: Outputs to a file
$ cat afile >> bfile
appends the contents of the file afile to the end of the file bfile and
$ cmd >> bfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 08:25 AM
06-11-2003 08:25 AM
Re: Outputs to a file
exec >/tmp/mylog 2>&1
at the top of the script to redirect all output (STDOUT and STDERR) to mylog. Then all output from all commands will be redirected.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2003 08:42 AM
06-11-2003 08:42 AM
Re: Outputs to a file
I prefer separating output and error:
# command 1>> out.log 2>>err.log
eg.
# date 1>>log 2>>err