🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Help with cp command

Started by
2 comments, last by erissian 16 years, 11 months ago
Hi, Imagine I have the following directories and files in my home directory: dir1/a.1 dir1/a.2 dir1/junk.2 dir1/otherjunk.3 dir2/b.1 dir2/b.2 dir2/junk.2 dir2/otherjunk.3 ... dir72/x2.1 dir72/x2.2 dir72/junk.2 dir72/otherjunk.3 Now I want to copy over all the ".1" files into a new directory, while keeping them in their sub-directories (thus making copies of the sub-directories as well), while NOT copying over all the other file types (".2", ".3", etc). So if I'm copying stuff over into a folder called "temp," it'll end up looking like this: temp/dir1/a.1 temp/dir2/b.1 ... temp/dir72/x2.1 How can I do this with the cp command (or any other command)? Thanks
Advertisement
Take a look at rsync. Off the top of my head, something like this should do:

rsync -a --exclude=* --include=*.1 /path-from /path-to

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

cp --parents `find -name "*.1"` temp
I just want to jump on the bandwagon:

cp --parents */*.1 temp
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)

This topic is closed to new replies.

Advertisement