...
As described in a section of Linux Fundamentals page, there are three built-in, Standard Streams, each with a well-defined stream number:
- 0 - standard input
- 1 - standard output
- 2 - standard error
Redirection characters allow you to control the stream input or output
...
- redirect standard output to a file, overwriting any exiting contents:
echo "Output text" > out.txt
echo "Output
textMore output" 1> out.txt - redirect standard output to a file, appending to any exiting contents:
echo "More Some text" >> out.txt
echo "More text" 1>> out.txt - redirect standard error output to a file, overwriting any exiting contents:
echo "Error
text" 2> ls xxxx 2> err.txt - redirect standard error to standard output:
ls xxxx > ls.log 2>&1
- redirect standard output to standard error:
echo "
Output that will go to standard error
" 1>&2
...
Code Block | ||
---|---|---|
| ||
# list 2 files, one that exists and one that does not
ls ~/.profile ~/xxx |
Produces this output:
Code Block |
---|
ls: cannot access 'xxx': No such file or directory .profile |
...
We've also added command-line processing and usage support for the new functions.
argument defaulting
...