|
|
|
@ -37,9 +37,11 @@ echo ${PIPESTATUS[0]} # replace 0 with N
|
|
|
|
|
# for loop in one line
|
|
|
|
|
for i in $(seq 1 4); do echo $i; done
|
|
|
|
|
|
|
|
|
|
# Test if a program exists in the path
|
|
|
|
|
command -v <program> 2>&1 >/dev/null || error "<program> not installed"
|
|
|
|
|
# Test if a program exists in the path
|
|
|
|
|
# There are false positives: aliases and functions
|
|
|
|
|
command -v ${program} >/dev/null 2>&1 || error "${program} not installed"
|
|
|
|
|
|
|
|
|
|
# Redirection
|
|
|
|
|
my_command 2>&1 > command-stdout-stderr.txt
|
|
|
|
|
my_command 2>&1 > /dev/null
|
|
|
|
|
# Please note that 2>&1 goes after
|
|
|
|
|
my_command > command-stdout-stderr.txt 2>&1
|
|
|
|
|
my_command > /dev/null 2>&1
|
|
|
|
|