Difference between revisions of "/dev/stderr"

From wikieduonline
Jump to navigation Jump to search
Line 16: Line 16:
  
 
* [[Google style guide]]: https://google.github.io/styleguide/shellguide.html#stdout-vs-stderr
 
* [[Google style guide]]: https://google.github.io/styleguide/shellguide.html#stdout-vs-stderr
 +
err() {
 +
  echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
 +
}
 +
 +
if ! do_something; then
 +
  [[err]] "Unable to do_something"
 +
  exit 1
 +
fi
 +
  
 
== Related ==
 
== Related ==

Revision as of 10:21, 16 November 2022

wikipedia:stderr


your-command-with-stdout-and-stderr 2>&1 | tee -a your file



err() {
  echo "[$(date +'%Y-%m-%dT%H:%M:%S%z')]: $*" >&2
}

if ! do_something; then
  err "Unable to do_something"
  exit 1
fi


Related

See also

Advertising: