Reputation: 1285
I have a query on unix move for files not matching pattern. Example below:
Directory listing
20150325
20150326
20150327
20150328
archieve
Now, I want to move all the files not matching 20150328 into archieve directory with a single command. Please help......
Upvotes: 1
Views: 1944
Reputation: 4025
find with the -name parameter and the ! negation operator:
find . -type f ! -name 20150328 -exec mv {} archieve \;
The {} matches the file just found, and the escaped semi-colon terminates the exec'ed command.
To exclude multiple files, just repeat the ! -name filename
clause
Upvotes: 2
Reputation: 133
execute: shopt -s extglob
after that do: mv !(20150328) "destination"
Upvotes: 1