Reputation: 211
I am new to shell scripting.
I have a command which copies all tml/xml
files in the current directly to another as below:
cp -f *.[tx]ml $path
But I need to exclude one file (excludeme.xml) while executing the above command.
I tried the below command but did not work.
find . -name "excludeme.xml" | xargs -0 -I {} cp -f *.[tx]ml $path
Upvotes: 1
Views: 1566
Reputation: 246799
If this is bash
then
shopt -s extglob
cp !(excludeme).[tx]ml destination
Upvotes: 2
Reputation: 212248
Try:
find . ! -name excludeme.xml | ...
or
ls *.[tx]ml | while read -r file; do test x"$file" = xexcludeme.xml || cp -f "$file" "$path" done
Note the leading 'x'; it is probably not necessary in modern shells, but will prevent errors when the file name begins with '-'.
Upvotes: 2