I have created a simple script to move all the files with .sh
suffix in the current working directory to a designated directory
If there was no such file, the script should output only an error message that I have entered, not the system error message: mv: cannot stat ‘*.sh’: No such file or directory
I tried adding ./shm 2> /dev/null
after the mv
command put that caused the script to run with no stop!
How can I mute the systems error message?
#!/bin/bash
echo "Moving all script files to script directory..."
mv *.sh $HOME/linux/scripts
#./shm 2> /dev/null
if [ $? -ne 0 ]
then
echo "No files with .sh suffix"
fi