LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


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

Rep: Reputation: 0
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!
 
Old 02-12-2011, 12:56 AM   #2
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,538

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

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


Reply


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 05:57 PM
Copy files in subdirs to one dir Rotwang Linux - General 4 12-14-2007 02:30 PM
Copy files from different directories fiomba Linux - Software 3 02-11-2005 04:01 AM
Why doesn't a wildcard chmod change "dot" files/directories? jht2k Linux - General 1 08-09-2004 03:31 PM
check for matching files when comparing directories WarriorWarren Linux - General 3 05-07-2003 02:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

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