avoid displaying errors while executing a script

Hi all,

I am running a script on bash shell, although it gives me the desired output, it displays some errors at the prompt like

this directory doesnt exists
unary operator
etc etc

Is there someway to avoid these errors ??
Its very annoying to have these errors while the script is executing.

Thanks

The code is trying to do something to, or to a file, in a directory that does not exist.

This means a "test" statement is failing, not just the condition not being met but the syntax is plain wrong.

To me, these errors mean there is something inherently wrong in the script that warrents investigation, not hiding under the carpet.

Fist solution (the worst) : Ignore errors and redirec error output to null device
At the begining of the script :

exec 2>/dev/null

Second solution (simply the best) : Correct errors in script.
A way to determine the origine of the error is to execute the script with the debug option -x

Jean-Pierre

hey, I just gave an example. I dont remember the exact error i am getting.
I ws just thinking if I could just avoid these kinda errors. I dont want to modify my script now.
thanks.

Thanks,
Both of you solutions working fine for me. Will try to debug the script.
Thank you so much