Reputation: 2785
I tried with the following command:
cp src_folder/[!String]* dest_folder
However, this command will copy all the files that don't start with any of the characters 'S','t','r','i','n','g' instead of copying files that don't start with "String".
Upvotes: 8
Views: 18181
Reputation: 37467
A variation on Konrad answer, using cp
option -t
to specify target directory simplifies the last command. It creates a single cp
process to copy all the files.
ls src_folder | grep -v '^String' | xargs cp -t dest_folder
src_folder
String
dest_dir
Upvotes: 15
Reputation: 799110
In bash:
shopt -s extglob
cp src_folder/!(String*) dest_folder
Upvotes: 5
Reputation: 545875
ls src_folder | grep -v '^String' | xargs -J % -n1 cp % dest_folder
This will
src_folder
String
(so that the rest remains)cp
command
-n1
says to call cp
for each of them separately)% dest_folder
, where %
is replaced by the actual file name.Upvotes: 3