2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-19 03:25:44 +00:00
This commit is contained in:
Igor Chubin 2017-12-03 13:05:35 +00:00
commit fbe957f77d

View File

@ -38,8 +38,10 @@ echo ${PIPESTATUS[0]} # replace 0 with N
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"
# 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