Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-11-2011, 10:33 PM   #1
LQ Newbie
Registered: Feb 2011
Posts: 1

Rep: Reputation: 0
copy wildcard files from directories to matching ones in another dir


I have 2 massive duplicate dirs of the same format as below:


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...

Old 02-11-2011, 11:56 PM   #2
Senior Member
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Rep: Reputation: 110Reputation: 110
Maybe you should go with 'cp -aux' or read 'man rsync'.

Learning rsync is highly recommended, it's a wonderful application.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a script to move or copy files into multiple directories below the files matthes138 Linux - Newbie 5 08-25-2009 04:57 PM
Copy files in subdirs to one dir Rotwang Linux - General 4 12-14-2007 01:30 PM
Copy files from different directories fiomba Linux - Software 3 02-11-2005 03:01 AM
Why doesn't a wildcard chmod change "dot" files/directories? jht2k Linux - General 1 08-09-2004 02:31 PM
check for matching files when comparing directories WarriorWarren Linux - General 3 05-07-2003 01:40 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:32 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration