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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:43 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
Open Source Consulting | Domain Registration