letiantian
letiantian

Reputation: 437

How to compress files with specified suffix in subdirectory?

For example, current directory is /A/B/, some scripts whose suffixes are .py and .sh in /A/B/C/,/A/B/C/D/ and /A/B/E/.

How to generate such a compressed file which has the structure of directories and contains the python /shell scripts?

Upvotes: 1

Views: 223

Answers (2)

Patrick Maupin
Patrick Maupin

Reputation: 8137

Use find with your compression, e.g.:

zip outfile -r `find . -name '*.py'` `find . -name '*.sh'`

Upvotes: 1

Chris Burgin
Chris Burgin

Reputation: 256

find ./someDir -name ".php" -o -name ".html" | tar -cf my_archive -T -

as seen here in a question very similar to yours. How to tar certain file types in all subdirectories?

Upvotes: 1

Related Questions