Jump to content
  • Advertisement
Sign in to follow this  
Haytil

Help with cp command

This topic is 4163 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!