Reputation: 1105
I try to copy some files from a folder to another. I want to copy all them except some that begins with the same pattern, quality*.csv. I use the next code but it doesn't run.
#!/bin/bash
dir=/home/meteo/data
dir1=/home/meteo/data2
cd $dir
find . ! -name qualitat*.csv cp $dir1
what is wrong? thks
Upvotes: 1
Views: 80
Reputation: 784968
You need to use -exec
option in find
:
find . -type f ! -name "qualitat*.csv" -exec cp '{}' "$dir1" \;
OR using xargs
:
find . -type f ! -name "qualitat*.csv" -print0 | xargs -0 cp {} "$dir1"
Upvotes: 1