Recently I wanted to send a zip file with a password for sending confidential data to a colleague. But I didn't want to download a separate app for it.

Luckily there is a easy command line tool for it called - I could have guessed - zip with a parameter e to set a password. So to zip a single file use the following command:

zip -e path/to/result.zip path/to/source-file.sql

If you want to zip a folder, use the r flag:

zip -er path/to/result.zip path/to/folder