Performing an operation on multiple files using a single command line in bash

This is quite useful if you need to move files from multiple locations to a single place.

Let's assume that you have been searching for all *.jpg files on your system and you need to move all of them to a specific folder /home/deadpan/images,

To get the files do,

$ find . -name "*.jpg" . This would get you all the .jpg files.

To move all these files from various location to a single folder do,

$ for file in `find . -name "*.jpg"`; do mv $file /home/deadpan/images; done

By using regular expressions in find, as discussed here, you can get very specific in your search.