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.


I think this sort of "noise" is not uncommon, that's why you often do this:

pushd > /dev/null
| improve this answer | |
  • 1
    You can also make a function to basically redefine the command and stick it in .bashrc such as: pushd() { builtin pushd $1 > /dev/null; } – violet Feb 1 '10 at 2:02
  • 5
    @jrod: Since pushd can takes multiple arguments, you might want that as pushd() { builtin pushd "$@" > /dev/null; } and the quotes handle directory names with spaces. – Paused until further notice. Feb 1 '10 at 2:52
  • 3
    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. – vidstige Jan 15 '15 at 17:54
  • 1
    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. – Shital Shah Jul 21 '17 at 0:35
  • 1
    popd also generates console output, so consider silencing it in the same way – Clare Macrae Mar 11 '18 at 18:01

For the tcsh shell you can: set pushdsilent

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.