Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zip together all HTML files under current directory

I am looking to zip together *.html files recursively under the current directory.

My current command is:

zip all-html-files.zip *.html 

But this doesn't work recursively. Nor does adding the -r option it seems. Can anybody advise? I want to zip all html files under the current directory, including those underneath subdirectories, but zip the HTML files only, not their file folders.

Thanks!

like image 497
Barney Avatar asked Dec 26 '22 01:12

Barney


1 Answers

What about this?

find /your/path/ -type f -name "*.html" | xargs zip all_html_files.zip

looks for all .html files under the directory /your/path (change it for yours). Then, pipes the result to xargs, which creates the zip file.

To junk the paths, add -j option:

find /your/path/ -type f -name "*.html" | xargs zip -j all_html_files.zip
like image 156
fedorqui 'SO stop harming' Avatar answered Jan 07 '23 17:01

fedorqui 'SO stop harming'