Standard output

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to: navigation, search
← Standard inputHomeStandard error →
  • Standard output is used by a command to writes (display) its output.
  • The default is the screen.
  • It is denoted by one number (1).
  • Also known as stdout.
  • The default standard output is the screen.
  • > is output redirection symbol and syntax is:
command > output.file.name

For example, ls command by default writes its output to the screen:

ls

But, you can save the output to a file called output.txt, enter:

ls > /tmp/output.txt
Shell - writing output to a file.

To view file, enter:

cat /tmp/output.txt
  • Please note that /tmp/output.txt file is created if it doesn't exist. And if file /tmp/output.txt file is overwritten if it exits.
  • You can also save your script output to the file:
./your.script.name.sh > myoutput
cat myoutput
← Standard inputHomeStandard error →