I have a script with many commands. Like
#!/bin/sh
mv new /root/
mv old /root/
mv foo /code
#many other commands
If the file 'new' is not found bash will give an error message:foo: No such file or directory
I can suppress the error message by redirecting all output from stderr to /dev/null
mv foo /code 2>1 /dev/null
Questions:
Is there a way to simply do it without modifying whole script?
Is there a way in which to suppress all the error message in a script?
./myscript.sh 2 > /dev/null