Skip to content
Advertisement

Copy bulk files to another destination using a given prefix in bash

I want to copy all the files newer than another one from their original location /lib/ into another destination /dest/lib/

To identify these files I simply use:

JavaScript

Unfortunately I cannot simply use this command because cp does not know how to create folders on the fly.

So I used this command:

JavaScript

This looks very complicated and is incredibly slow. Is there a better solution?

Advertisement

Answer

You can use tar for this, for example, let’s you have directory ‘1’, and you want copy something to directory ‘2’, then:

JavaScript

also you can use rsync it works with local paths

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement