How to search inside tar.gz file without opening it on Windows 11

Yes, you can search inside a tar.gz file without extracting it, and in this guide, you will learn how on Windows 11.

Windows 11 search inside tar.gz
Windows 11 search inside tar.gz
  • 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

To perform a file search inside a “tar.gz” file without extracting it, use these steps:

  1. Open Start on Windows 11.

  2. Search for Ubuntu and click the top result to launch the WSL distro.

  3. Type the following command to search inside a tar.gz file and press Enter:

    tar -tf TAR.GZ-FILE-PATH | grep SEARCH-TERM

    Search inside tar.gz

    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:

  1. Open Start.

  2. Search for Ubuntu and click the top result to launch the WSL distro.

  3. 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

    Extract specific tar.gz files

    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.

About the author

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 15 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 21 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter), YouTube, LinkedIn and About.me. Email him at [email protected].