LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Capturing the Output of the command (https://www.linuxquestions.org/questions/linux-newbie-8/capturing-the-output-of-the-command-4175577832/)

SoLostNConfused 04-19-2016 09:31 AM

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

suicidaleggroll 04-19-2016 09:50 AM

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.

michaelk 04-19-2016 09:56 AM

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?

Habitual 04-19-2016 10:09 AM

See also http://www.tldp.org/LDP/abs/html/io-redirection.html

Welcome to LQ!


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