SSH zip only certain types of files recursively on Linux

If you are looking for a command to run via ssh that ZIPs all files (of a certain type) recursively here you go:

1 - Switch into the website folder, then run

zip -R YOURZIPFILENAME '*.php' '*.html' '*.js' '*.css' 

2 - You can also run this from outside the website folder:

zip -r YOURZIPFILENAME website_folder -i '*.php' '*.html' '*.js' '*.css'

Then simply FTP into that site and download your ZIP file.

Make sure put single quotes around the pattern(s) you want to match, otherwise the shell will expand them before executing zip and you'll just end up with matching files in the current directory.

Comments are closed.