Linux one liner to copy files with directory structure


Here is another one liner to find multiple file types and copy them along with the directory structure to the destination.

I was searching for copying all pics and video files from my computer to USB hard drive. While googling around I got this command.

find /home -regextype posix-extended -regex ‘.*(MOV|JPG)’ -exec cp –parents {} /media/vin/desktop \; -print

This can be handy when you don’t want to loose the directory structure and want to copy all similar type of files in one go. Above command looks complex but still it is one line command.. Have fun with Linux and you’ll enjoy exploring this OS 🙂

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s