Placing an exclamation mark before a
find condition reverses its logic -e.g.:
find / ! -name "*.txt" ! -name "*.doc"
... will return the filepaths of all files whose names do not end with .doc or .txt - this provides a list which can then be used in a for loop:
Code:
#note that those are back-ticks round find statement, not single quotes
for file in `find / ! -name "*.txt" ! -name "*.doc"`
do
cp $file ${newdir}$file
done