I want to create zip of a folder from command-line. I can do something like
zip -r folder.zip folder. I want to give the zipped folder same name as the original folder. I can simulate this by writing a script:

zip -r $1 $1  

And then doing ./script folder.

Is it possible to do this without writing any script?


This is how you do it straight with the shell:

zip -r folder{.zip,}

You can add a bash function that does this to your .bashrc file:

function fzip {
    zip -r $1 $1

Then in the shell you can do:

user@host:~$ fzip my_folder
# creates my_folder.zip
  • 1
    A bash function IS a script
    – phil294
    Dec 5 '16 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.