0

I have a bunch of folders in an external HDD and I want to copy a part of them. The folders have the following structure:

A001A A003A A004A etc... 

...and all the folders contain similar directories e.g:

HHZ HH1 HH2 LHZ LH1 LH2 

I need to copy all the directories (A001A, A002A ...) with the subdirectories (HHZ, HH1, HH2) but with only the directories with H initial (also every files in it).

How can I do that?

2 Answers 2

0

This should do the trick (assuming all the directories in the current folder are A*** directories):

cp -r --parents */H* destination/

You should obviously replace destination/ with your actual target.

0

If your pax supports the -0 option (and your find the -print0 predicate):

find . -path '*/H*' -print0 | pax -0rwpe /dest/dir/ 

Would copy all the files and directories that /H in their path.

If they don't but you can guarantee file paths don't contain newline characters, you can remove both 0s in the command above.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.