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
Share:
17,679
Araejay
Author by

Araejay

Updated on September 17, 2022

Comments

  • Araejay
    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
    violet over 14 years
    You can also make a function to basically redefine the command and stick it in .bashrc such as: pushd() { builtin pushd $1 > /dev/null; }
  • Araejay
    Araejay over 14 years
    Good tip, but most unix tools don't print to the terminal EVERY TIME, but only if there's an error
  • vidstige
    vidstige over 9 years
    I'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
    Shital Shah almost 7 years
    Some 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.