Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- echo "This is standard output"
- echo "This is an error" >&2
- #as a function
- echoerr() {
- echo "$@" 1>&2;
- }
- echoerr "This is another error"
- echo "this is more standard output"
- echo "You can also use /dev/stderr for standard error output" >>/dev/stderr
- ###view only the standard out
- #./stio.sh 1> /dev/null
- ###This will save standard output and display only standard error
- #./stio.sh > test.log
- ###IF you want to save both standard output and error
- #./stio.sh > output.txt 2>&1
- ###Another example
- #find / -name "test.png" > output.txt 2>&1
- #find / -name "test.png" 2>/dev/null
Add Comment
Please, Sign In to add comment