Is there a command-line shortcut for ">/dev/null 2>&1"
You can write a function for this:
function nullify() { "$@" >/dev/null 2>&1}
To use this function:
nullify program arg1 arg2 ...
Of course, you can name the function whatever you want. It can be a single character for example.
By the way, you can use exec
to redirect stdout
and stderr
to /dev/null
temporarily. I don't know if this is helpful in your case, but I thought of sharing it.
# Save stdout, stderr to file descriptors 6, 7 respectively.exec 6>&1 7>&2# Redirect stdout, stderr to /dev/nullexec 1>/dev/null 2>/dev/null# Run program.program arg1 arg2 ...# Restore stdout, stderr.exec 1>&6 2>&7