HI ,
I am tryin to copying multiple files from some dir. If the files are not present. It should not throw error in the screen. HOw to do that . Please help
HI ,
I am tryin to copying multiple files from some dir. If the files are not present. It should not throw error in the screen. HOw to do that . Please help
cp src_file dest_file 2>/dev/null
--ahamed
redirect stderr ..
cp filea fileb 2>/dev/null
Thnx ahamed101 & thegeek
And much better will be:
[[ -f src_file ]] && cp src_file dest_file 2>/dev/null
So with above code, even if you don't have the source file, the script won't call cp command unnecessary. Also, it gives you flexibility to trap the information about missing file as well if you call in nested if - else statement