LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-19-2013, 12:00 AM   #1
Saratha
LQ Newbie
 
Registered: Mar 2013
Posts: 4

Rep: Reputation: Disabled
Question Appending Error to a File in unix script


Hi

Can anyone help me to append error of a command to a file.
I tried using >>filename but the error is not getting appended to the File.

Thanks in Advance
Saratha
 
Old 04-19-2013, 01:00 AM   #2
roger_heslop
Member
 
Registered: Oct 2009
Location: Leander, TX
Distribution: Fedora 20
Posts: 97

Rep: Reputation: 35
Using >> will only append standard output (stdout), not standard error (stderr). 2> is used to redirect stderr, but may not append.

>>& is suggested by the link below, for appending both stdout and stderr.

http://sc.tamu.edu/help/general/unix/redirection.html
 
Old 04-19-2013, 01:41 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,260

Rep: Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328Reputation: 2328
To capture both stdout & stderr, I use
Code:
prog >prog.log 2>&1
which works just fine.
 
Old 04-19-2013, 03:14 AM   #4
kooru
Senior Member
 
Registered: Sep 2012
Posts: 1,385

Rep: Reputation: 273Reputation: 273Reputation: 273
Hi Saratha,

2>filename to redirect stderr to your file.
If you want more info: http://www.tldp.org/LDP/abs/html/io-redirection.html
 
1 members found this post helpful.
Old 04-19-2013, 04:19 AM   #5
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Check following links for helpful informations on I/O redirections and file descriptors:

http://www.tldp.org/LDP/abs/html/io-redirection.html
http://mywiki.wooledge.org/FileDescriptor
 
  


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
Unix script - Delete particular words in a file Hoxygen232 Programming 10 03-30-2013 03:00 PM
[SOLVED] shell script for appending data to a file etika Linux - Newbie 3 02-08-2011 08:56 PM
How to run bat file from Unix script??? gopi_20us Programming 10 09-14-2010 10:15 AM
need to write a shell script for appending text into each line of a file nandakv4 Programming 9 08-15-2009 04:32 AM
Unix script : Append to a file linux_newbee Linux - Newbie 2 06-08-2006 02:12 PM


All times are GMT -5. The time now is 10:44 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration