How to make cp command quiet when no file is found in Bash?
Well everyone has suggested that redirecting to /dev/null would prevent you from seeing the error, but here is another way. Test if the file exists and if it does, execute the cp command. [[ -e f.txt ]] && cp f.txt ff.txt In this case, if the first test fails, then cp will never run and …