Linux - Extract all tar files in a directory

Multiple tar files in a directory and want to extract them all?

This works in the Bash shell:

for a in `ls -1 *.tar.gz`; do tar -zxvf $a; done

2 Responses to “Linux - Extract all tar files in a directory”

  1. tamon Says:

    Hello there,

    After running the above command, I get the following errors:

    ls: No match.
    for: Command not found.
    a: Undefined variable.

  2. Bill Gross Says:

    Tamon;

    Make sure you have the correct apostrophy marks. They must be the “backward” apostrophy. On my MB it’s above the tab key, on my Dell it’s also above the tab key.

    Bill

Leave a Reply