gzip many files one by one

6,465

To compress all files, you can use:

gzip n*.txt

The n*.txt will expand to all file names as arguments for gzip.

Share:
6,465

Related videos on Youtube

slhck
Author by

slhck

Updated on September 18, 2022

Comments

  • slhck
    slhck over 1 year

    I have 100 files, n1.txt, n2.txt,… and I want to gzip each of them, but not in one file – finally I'd like to have 100 n*.txt.gz files.

    How can I do that in Linux with Bash?

    • Kevin Versfeld
      Kevin Versfeld about 11 years
      Did you check the man pages? They are great when you need to get help on the allowed syntax of a command.
    • jpaugh
      jpaugh almost 6 years
      Note that gzip does not allow compressing multiple files into one archive, because it's not an archive format (only a compression format). For that, you need to use tar, and compress the resulting tar archive with gzip.