Difference between revisions of "/dev/stderr"
Jump to navigation
Jump to search
m (Welcome moved page Stderr to /dev/stderr) |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 10: | Line 10: | ||
− | your-command-with-stdout-and-stderr 2>&1 | tee -a your file | + | your-command-with-stdout-and-stderr 2>&1 | [[tee -a]] your file |
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 == | ||
* [[CKA: Manage container stdout & stderr logs]] | * [[CKA: Manage container stdout & stderr logs]] | ||
* <code>[[gcloud]]</code> | * <code>[[gcloud]]</code> | ||
+ | * [[tee -a]] | ||
== See also == | == See also == | ||
* {{stdin}} | * {{stdin}} | ||
* {{logging}} | * {{logging}} | ||
+ | * {{shell}} | ||
[[Category:Linux]] | [[Category:Linux]] |
Latest revision as of 11:37, 15 February 2024
2>&1
&>
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[edit]
See also[edit]
- Standard streams:
/dev/stdin
,/dev/stdout
,/dev/stderr
,/dev/null
, File descriptor,set -x, 2>&1, stdbuf
- Linux logging, Cisco IOS logging
- Shell: Fish shell,
sh
,Bash
,ksh
,zsh
,ash
, PowerShell (Windows),/usr/bin/env
,.hushlogin
,dash
,tcsh
, Shell redirection,dquote, $SHELL
, Google Cloud Shell, AWS CloudShell, explainshell.com, vmware_vm_shell, Nushell, Fig.io, direnv
Advertising: