Finding and copying files in Bash

Another useful tip to store away, the find command lets you find files and you can use the xargs command to copy them somewhere else, simply the pipe the output from find into xargs:

find /media/cdrom/ -name '*27918*' | xargs -i cp {} ~/Desktop/

This then copies anything with 27918 in the title to your desktop, which is much quicker than searching through every file on the cdrom for example.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s