Extract and delete all .gz in a directory- Linux Extract and delete all .gz in a directory- Linux linux linux

Extract and delete all .gz in a directory- Linux


@techedemic is correct but is missing '.' to mention the current directory, and this command go throught all subdirectories.

find . -name '*.gz' -exec gunzip '{}' \;


There's more than one way to do this obviously.

    # This will find files recursively (you can limit it by using some 'find' parameters.     # see the man pages    # Final backslash required for exec example to work    find . -name '*.gz' -exec gunzip '{}' \;    # This will do it only in the current directory    for a in *.gz; do gunzip $a; done

I'm sure there's other ways as well, but this is probably the simplest.

And to remove it, just do a rm -rf *.gz in the applicable directory