I searched map cp
, but can find no quiet option, so that cp
does not report "No such file or directory".
How can I make cp
not print this error if it attempts, but fails, to copy the file?
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 hence no error.