37

Say I have a list of files a.txt, b.txt, c.txt, is it possible to pass it to zip command as arguments and make it zip it in one file say a.zip?

muru
  • 193,181
  • 53
  • 473
  • 722
william007
  • 557
  • 1
  • 6
  • 13

1 Answers1

63

Sure. The man page of zip says you can specify [file ...] on the command line. This notation says you can specify multiple files separated by spaces, like this:

zip a.zip a.txt b.txt c.txt

You can also utilize pathname expansion. The shell will replace wildcards used in the filename with all matching filenames. Example:

zip a.zip *.txt
Melebius
  • 11,121
  • 8
  • 50
  • 77