Quantcast
Channel: Find and move with exclude - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 5

Answer by AntumDeluge for Find and move with exclude

$
0
0

Using "find" command:

find ./*.xml -type f ! -name "deposit.xml" -exec mv {} ./Archive ';'

Using "find" with "xargs" command:

find ./*.xml -type f ! -name "deposit.xml" | xargs -I {} mv {} ./Archive

Using "for" loop with "find" command.

for f in $(find ./*.xml -type f ! -name "deposit.xml"); do mv ${f} ./Archive; done

Also, according to the manpage for GNU/Linux systems, the "mv" command has the "-t | --target-directory" option. So you should be able to use it with "xargs" like this:

find ./*.xml -type f ! -name "deposit.xml" | xargs mv -t ./Archive

I have not tested that though as I am on a FreeBSD system.


Viewing all articles
Browse latest Browse all 5

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>