cp: silence "omitting directory" warning
bash, cp
Solution
Probably you want to use `cp -r` in that script. That would copy the source recursively including directories. Directories will get copied and the messages will disappear.
If you don't want to copy directories you can do the following:
- redirect stderr to stdout using `2>&1`
- pipe the output to grep -v
script 2>&1 | grep -v 'omitting directory'
quote from grep man page:
-v, --invert-match
Invert the sense of matching, to select non-matching lines.
Problem
I'm using the command `cp ./* "backup_$timestamp"` in a bash script to backup all files in directory into a backup folder in a subdirectory. This works fine, but the script keeps outputting warning messages: ``` cp: omitting directory `./backup_1364935268' ``` How do I tell cp to shut up without silencing any other warnings that I might want to know about?