notes/Working with Standard Error and Output in BASH Linux shell-S4PqS7tv.sh
#!/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

syntax highlighted by Code2HTML, v. 0.9.1