Reputation: 2183
I have built script for copying multiple folders and files matching file types in one cp
command line only like below:
today=$(date +"%d-%m-%Y");
cp -r ./{dir1,dir2,dir3,..,fi.le1.ext1,*.ext2,*.ext3} "../Target_$today/Subdir_$today/"
Now I want to copy all files of ".ext3" but leave out files that contain "lock" or "-lock" in their name. Because those files are auto-generated and so not required to backup those(eg. package-lock.json).
How can I do that without adding any find
statement in between, but only using wildcard and negation operators ?
Upvotes: 1
Views: 107
Reputation: 785571
Using extended glob:
shopt -s extglob nullglob
cp -r ./{dir1,dir2,dir3,..,fi.le1.ext1,!(*lock).ext2,*.ext3} "../Target_$today/Subdir_$today/"
Upvotes: 4