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!

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

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.