LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 07-17-2003, 07:23 AM   #1
lido
Member
 
Registered: Jul 2003
Posts: 34

Rep: Reputation: 15
File descriptor


Hi all,

I've come across this file descriptor but don't really understand how it is done. I understand that 2 is for standard error and 1 is for standard output, but still don't understand fully. Appreciate if someone can explain to me in layman's term. And how can I read up for more information in the info page for the > operator? I'm not able to find any information with "info >". Thanks alot

ls>dirlist 2>&1
-will direct both standard output and standard error to the file dirlist

ls 2>&1>dirlist
- will only direct standard output to dirlist.
 
Old 07-17-2003, 07:30 AM   #2
fancypiper
LQ Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 58
That's re-direction.

# Basic piping
some_command | another_command
See Linux and the tools philosophy
# Basic re-direction:
command > textfile_name
See this Text Manipulation Article
# Basic concatenation:
If you don't want to overwrite a file but add to the bottom of an existing file, concatenate it:
command >> exisiting_text_file

Last edited by fancypiper; 07-17-2003 at 07:37 AM.
 
Old 07-17-2003, 08:04 AM   #3
lido
Member
 
Registered: Jul 2003
Posts: 34

Original Poster
Rep: Reputation: 15
ls>dirlist 2>&1

Regarding the above statement, fom my understanding, the output of ls is redirected to dirlist. but what does 2>&1 means? How does it redirect the output and error to dirlist since it's using the greater symbol ">"??
 
Old 07-17-2003, 08:19 AM   #4
fancypiper
LQ Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 58
Perhaps the Rute guide can explain better than I can.

Redirecting Streams with >&
 
Old 07-17-2003, 11:52 AM   #5
lido
Member
 
Registered: Jul 2003
Posts: 34

Original Poster
Rep: Reputation: 15
Hi fancypiper,

That's a very good link for beginner. Thank you very much
 
Old 07-17-2003, 12:58 PM   #6
fancypiper
LQ Guru
 
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 58
I have got to get that in hard cover. It's absolutely the best explanation of Linux I have found.
 
  


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
Get the absolute path of file using file descriptor. appas Programming 7 01-19-2012 12:47 PM
Change File Descriptor ilnli Linux - General 1 05-15-2005 06:43 PM
File Descriptor Limit rbd Linux - General 3 10-11-2004 02:57 PM
apt-file returns nothing; 'bad file descriptor' overbored Debian 3 10-03-2004 10:13 PM
[c++] How can I get a file descriptor from a c++ i/o stream? chuanyung Programming 8 03-09-2004 12:23 AM


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