LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-24-2005, 05:49 PM   #1
Hockeyfan
Member
 
Registered: May 2004
Distribution: SuSe 10.0
Posts: 154

Rep: Reputation: 30
writing output to file


What is the command to write the output of the comand to a file?

I think it goes something like this:

ls -l 2&>1 outputfile

Am I right? I tried that and I got an file wriiten but it didn't work.

Hockeyfan
 
Old 10-24-2005, 05:59 PM   #2
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,173

Rep: Reputation: 47
Try it without the numbers, like this:

ls -l > filename
 
Old 10-24-2005, 06:03 PM   #3
Hockeyfan
Member
 
Registered: May 2004
Distribution: SuSe 10.0
Posts: 154

Original Poster
Rep: Reputation: 30
Thanks I should have realized that. I think I use the numbers when there are errors in the output.
 
Old 10-24-2005, 08:02 PM   #4
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 56
There are two streams, stdout and stderr. stdout is standard output and stderr is where error messages go.
Code:
ls -l > file.txt  # will dump only stdout to file.txt
ls -l 2> file.txt  # will dump only stderr to file.txt
ls -l &> file.txt  # will dump both streams to file.txt
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dd: writing to `/dev/hdc': Input/output error derekpc Linux - General 1 12-01-2005 11:46 AM
why when redirecting output to a file any file extension seems to be fine? dr_zayus69 Linux - General 1 05-21-2005 04:09 AM
writing to file ej25 Programming 17 11-19-2004 11:23 AM
writing a strcutures to a file xemous Programming 2 09-03-2004 02:57 AM
the sound gives output when using mic but no output when run a music file medo Debian 0 04-19-2004 07:17 PM


All times are GMT -5. The time now is 05:03 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration