Bash
General
Standard streams
stdin(0): standard inputstdout(1): standard outputstderr(2): standard error
Redirections
>: redirect stdout2>: redirect stderr2>&1: redirect stderr to stdout
Tips and Tricks
Copy and create destination dir if it does not exist
There is no direct option for cpdirectly, mkdir needs to be used in combination.
sh
# Exemple utility function
cpd() {
mkdir -p "$(dirname "$2")" && cp "$1" "$2"
}See Stack Overflow thread
Git output to stderr even if successful
console output sent to stderr when it should be stdoutFrom ChatGPT:
Git Commands and Stderr: Some git commands, like git checkout and git pull, may write output to stderr as part of their normal operation, even if they succeed. This output may include things like status messages, warnings, or just notifications (like switching branches). These messages aren't necessarily errors, but they are still sent to stderr.
Dirty workaround:
bash
git checkout 2>&1
git pull 2>&1
git push 2>&1