- To search inside a “tar.gz” file on Windows 11, open Ubuntu on WSL and run the “tar -tf TAR.GZ-FILE-PATH | grep SEARCH-TERM” command, and to extract a specific file, run the “tar -xvf TAR.GZ-FILE-PATH –wildcards *SEARCH-TERM* -C EXTRACT/PATH” command.
On Windows 11, if you use the Windows Subsystem for Linux (WSL), you can quickly search for content inside a “tar.gz” (tarball) without extracting it, and in this guide, you will learn how.
If you have a tar.gz container with a lot of files, instead of extracting its contents to find a file, you can quickly run a search without extracting anything with the help of the “tar” and “grep” command tools. Although the operating system includes native “tar” support, you will still need access to the “grep” tool, and for this reason, using the WSL is the best option to search inside this container type.
This guide will teach you the steps to search and extract specific files from a tar.gz file on Windows 11.
- Search for files inside tar.gz container on Windows 11
- Extract specific files from tar.gz container on Windows 11
Search for files inside tar.gz container on Windows 11
To perform a file search inside a “tar.gz” file without extracting it, use these steps:
-
Open Start on Windows 11.
-
Search for Ubuntu and click the top result to launch the WSL distro.
-
Type the following command to search inside a tar.gz file and press Enter:
tar -tf TAR.GZ-FILE-PATH | grep SEARCH-TERM
In the command, specify the path and name of the “tar.gz” file and the search term. This example looks for the “WordPress” keyword inside the container:
tar -tf files/files.tar.gz | grep wordpress
Once you complete the steps, the command will output the search result highlighting the files matching the search keyword.
Extract specific files from tar.gz container on Windows 11
To extract specific files from a “tar.gz” file on Windows 11, use these steps:
-
Open Start.
-
Search for Ubuntu and click the top result to launch the WSL distro.
-
Type the following command to extract only specific files from a tar.gz file and press Enter:
tar -xvf TAR.GZ-FILE-PATH --wildcards *SEARCH-TERM* -C EXTRACT/PATH
In the command, specify the path and name of the “tar.gz” file and the search term to match the file name pattern of the files to extract. You also have to specify the path to extract the files. This example extracts the files that contain the “wordpress” keyword in the name:
tar -xvf files/files.tar.gz --wildcards *wordpress* -C files
. If you know the exact name of the file, you can ignore the “–wildcards” option and type the full name of the file instead.
After you complete the steps, the specific files will extract from the “tar.gz” archive to the destination you specified in the command. If you have to extract the entire contents of the tarball, you can also use these instructions.