To extract multiple .tar.gz files in a directory on Linux or Unix, you can use a loop in a shell script. Here is an example script that will extract all of the .tar.gz files in the current directory:
#!/bin/bash for file in *.tar.gz do tar -xzf "$file" done
Save the script as extract.sh and make it executable by running the following command:
chmod +x extract.sh
You can then run the script by typing ./extract.sh.
This script will loop through all of the .tar.gz files in the current directory and extract them using the tar command with the -xzf options. The -x option tells tar to extract the files, the -z option tells it to uncompress the files using gzip, and the -f option specifies the file to extract.
You can modify the script to extract .tar.gz files in a different directory by changing the *.tar.gz glob to the path of the directory you want to extract. For example, to extract .tar.gz files in the /tmp directory, you would use the following glob:
/tmp/*.tar.gz
Keep in mind that this script will overwrite any existing files with the same names as the ones being extracted. If you want to extract the .tar.gz files to a different directory and preserve the directory structure, you can use the -C option followed by the destination directory. For example:
tar -xzf "$file" -C /path/to/destination
This will extract the .tar.gz files to the /path/to/destination directory and preserve the original directory structure.