copy wildcard files from directories to matching ones in another dir
Hi,
I have 2 massive duplicate dirs of the same format as below:
dir1
subdir1
file1
subdir2
file1
subdir3
file1
...
dir2 is the same, but it has some newer files of the same name.
I want to copy all file1's from dir2 to the same name and folders in dir1.
So basically something like:
cp -pr bkpDir1/*/*-big.gif Dir2/*/*-big.gif
This works for singular cases:
cp -pr bkpDir1/uniquesubdir/*-big.gif Dir2/uniquesubdir/*-big.gif
But not for wildcards:
cp -pr bkpDir1/subdir*/*-big.gif Dir2/subdir*/*-big.gif
---
Anyway the aim is to do the first cp above, I have tried a few options using find...
Oh great! in trying to show an example stumbled upon a way that worked, while in dir2:
find */*-big.gif | xargs -i cp -rp {} ../dir1/{}
sure there are better ways also...
thanks!
|