0

Hi all
I just have questions about
how not to show messages after you execute a certain command.

for example whenever you execute "which xxx"
there will always be a message on the terminal
saying its path or command not found will be written.

is that possible to write a shell script file
without showing these kind of messages?

Thanks!

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by sknake
Featured Replies
  • 1
    sknake 1,622   7 Years Ago

    Send stdout and stderr to /dev/null: [code=bash] sk@sk:~$ which bash /bin/bash sk@sk:~$ which bash >> /dev/null 2>&1 sk@sk:~$ [/code] You can still access the return value which is usually why this is done. Here is an example: [code=bash] sk@sk:~$ which bash >> /dev/null 2>&1 sk@sk:~$ echo $? 0 sk@sk:~$ which … Read More

1

Send stdout and stderr to /dev/null:

sk@sk:~$ which bash
/bin/bash
sk@sk:~$ which bash >> /dev/null 2>&1
sk@sk:~$

You can still access the return value which is usually why this is done. Here is an example:

sk@sk:~$ which bash >> /dev/null 2>&1
sk@sk:~$ echo $?
0
sk@sk:~$ which asoija0cjas9cuasc >> /dev/null 2>&1
sk@sk:~$ echo $?
1
0

Thank you very much
problem solved!

Send stdout and stderr to /dev/null:

sk@sk:~$ which bash
/bin/bash
sk@sk:~$ which bash >> /dev/null 2>&1
sk@sk:~$

You can still access the return value which is usually why this is done. Here is an example:

sk@sk:~$ which bash >> /dev/null 2>&1
sk@sk:~$ echo $?
0
sk@sk:~$ which asoija0cjas9cuasc >> /dev/null 2>&1
sk@sk:~$ echo $?
1
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.