LinuxQuestions.org
Register a domain and help support LQ
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 08-20-2007, 06:40 AM   #1
hammertime1983
LQ Newbie
 
Registered: Mar 2007
Posts: 15

Rep: Reputation: Disabled
How to record an error command


Hello,

I'd like to know how to record an error outputed in bash. For example, if I typed cat notthere.txt it would save it to error.txt in the same folder.

Thanks.
 
Old 08-20-2007, 06:43 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Add an stderr redirection to a file after the actual command (redirections need to be the last in the line, order of them is not important unless you're using & to redirect one output to where ever another is going to). As an example, if you ran 'cat notthere.txt' and wanted the error to be saved to 'error.txt' in the same folder, you would redirect stderr (number 2; stdout is number 1, the usual output) like this:
Code:
cat notthere.txt 2>error.txt
 
Old 08-20-2007, 07:25 AM   #3
hammertime1983
LQ Newbie
 
Registered: Mar 2007
Posts: 15

Original Poster
Rep: Reputation: Disabled
Thanks, that's perfect! Just what I was looking for!
 
  


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
how can I record command history with times cjreeve Linux - Software 3 02-28-2007 09:56 AM
Master Boot Record Error SharkBait Slackware 5 03-16-2006 03:55 PM
error coding for record I/O in files shams Programming 3 08-29-2004 10:47 PM
Error while trying to record an Audio-CD with K3b diam0nd Linux - Software 5 06-18-2004 08:23 PM
Xsaw TV error[in it]Mdk9.1,can't record! akihandyman Linux - Newbie 0 01-29-2004 06:47 PM


All times are GMT -5. The time now is 07:10 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