2

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?

2
  • 2
    Did you check the man pages? They are great when you need to get help on the allowed syntax of a command. – mdpc Feb 18 '13 at 19:45
  • 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. – jpaugh Jul 27 '18 at 16:00
6

To compress all files, you can use:

gzip n*.txt

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

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.