In my script I have the following:
$cmd arg1 arg2 >/dev/null 2>&1
if [ $? -eq 0 ]; then
# cmd succeeds, do something
fi
Is there a way to make it shorter? I checked man test
for various options in []
command, but could not find anything that could make it shorter.
$cmd arg1 arg2 && do-the-things
. – U. Windl Feb 03 '22 at 20:56