Can I call pushd/popd and prevent it printing the stack?
17,679
I think this sort of "noise" is not uncommon, that's why you often do this:
pushd > /dev/null
Author by
Araejay
Updated on September 17, 2022Comments
-
Araejay almost 2 years
After calling
pushd
/popd
in bash, it will print off the current directory stack. Is there any way to prevent this behaviour, so that it will act 'quitely'? This sort of noise in a command is uncommon in unix tools. -
violet over 14 yearsYou can also make a function to basically redefine the command and stick it in
.bashrc
such as:pushd() { builtin pushd $1 > /dev/null; }
-
Araejay over 14 yearsGood tip, but most unix tools don't print to the terminal EVERY TIME, but only if there's an error
-
vidstige over 9 yearsI'd say its uncommon. The linux philosophy is actually to not print anything if everything went well except the output of the program or builtin if any. For example cd, ls, aso.
-
Shital Shah almost 7 yearsSome people do
pushd &> /dev/null
. I'd say don't do that because&
means redirect both stdout and stderr. Normally you only want to redirect stdout.