Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-19-2016, 09:31 AM   #1
LQ Newbie
Registered: Apr 2016
Posts: 1

Rep: Reputation: Disabled
Unhappy Capturing the Output of the command

I'm VERY new to Linux and confused/stuck on redirection and piping.

I'm reading a book and trying to figure out this scenario:

You want to capture the output of the command:
ls -l /home/user2 to a file so that you have a permanent record of the contents of user2's home directory. Which of the following procedures would allow you to do this?
a. redirecting standard input
b. redirecting standard error
c. redirecting standard output
d. none of the above

I THOUGHT it was c. redirecting standard output but judging from the Standard Output, Standard Input & Standard Error definitions I could not decipher which answer would best fit this scenario because none of them in the book mention specifically about capturing an output or having a permanent record of contents of a directory. Please help

Last edited by SoLostNConfused; 04-19-2016 at 10:44 AM.
Old 04-19-2016, 09:50 AM   #2
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2133Reputation: 2133Reputation: 2133Reputation: 2133Reputation: 2133Reputation: 2133Reputation: 2133Reputation: 2133Reputation: 2133Reputation: 2133Reputation: 2133
The normal output of a command goes to "standard output". If you want to save this information to a file, you would redirect "standard output" to said file. If you wanted to save the error information, you would redirect "standard error" to a file. If you wanted the program to read its input from a file rather than reading it interactively from your keyboard, you would redirect "standard input" to come from a file.

Last edited by suicidaleggroll; 04-19-2016 at 09:52 AM.
Old 04-19-2016, 09:56 AM   #3
Registered: Aug 2002
Posts: 18,913

Rep: Reputation: 2849Reputation: 2849Reputation: 2849Reputation: 2849Reputation: 2849Reputation: 2849Reputation: 2849Reputation: 2849Reputation: 2849Reputation: 2849Reputation: 2849
Welcome to LinuxQuestions.

Standard input is how data goes into a program which by default is the keyboard.

Standard output is how a program writes data which by default is the terminal. All the stuff that shows up after you press the enter key...

Standard error is how a program writes error messages which typically is the terminal.

So what standard i/o stream input, output or error would you expect the output of the ls command to fall under?

Last edited by michaelk; 04-19-2016 at 10:01 AM.
Old 04-19-2016, 10:09 AM   #4
LQ Veteran
Registered: Jan 2011
Location: Yawnstown, Ohio
Distribution: Mojave
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
See also

Welcome to LQ!


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
Capturing output of top command RHCE_ran Linux - Enterprise 2 05-15-2015 08:58 PM
[SOLVED] capturing output of command in vim editor sumeet inani Linux - Newbie 11 03-22-2011 02:01 AM
Capturing Output from net ads dns register Command jfmorales Linux - General 2 04-07-2010 03:07 PM
Capturing output from background FTP command Lazypete Linux - Server 6 05-22-2008 10:41 AM
expect_out(buffer) is not capturing all output from a Cisco IOS command eentonig Programming 1 01-30-2008 07:29 AM > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration