LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   File descriptor (https://www.linuxquestions.org/questions/linux-newbie-8/file-descriptor-73495/)

lido 07-17-2003 06:23 AM

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.

fancypiper 07-17-2003 06:30 AM

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

lido 07-17-2003 07:04 AM

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 ">"??

fancypiper 07-17-2003 07:19 AM

Perhaps the Rute guide can explain better than I can.

Redirecting Streams with >&

lido 07-17-2003 10:52 AM

Hi fancypiper,

That's a very good link for beginner. Thank you very much

fancypiper 07-17-2003 11:58 AM

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


All times are GMT -5. The time now is 08:20 PM.