regex - How to find specific text string in nested tar.gz archives? -


how find specific text string in source code files packed nested .tar.gz archives, packed inside anothe rar archive(48mb)? (on windows 7) tried use lookdisk, hangs , crash. possible find use system findstr utility, , what's regular expressions this? or other search utility, not need installation(portable).

based on superuser answer example batch file searches multiple .tar.gz archive files (specified on command line) , outputs filename of .tar.gz containing specified string.

it without outputting files disk.

it dependant on 7-zip, can use portable version of - doesn't need "installed" - available.

change value of variable searchstr (currently hell) string want search for.

i can't see obvious or easy way of returning filename of file containing text inside archive.

@echo off setlocal enabledelayedexpansion  set searchstr=hell  rem ensure 7z.exe in path or in current directory... ie. set path=%path%;c:\program files\7-zip  rem loop through commandline args - tar.gz files %%i in (%*) (      rem extract without intermediate .tar     7z x "%%i" -so | 7z x -si -ttar -so | findstr /c:"%searchstr%"      if "!errorlevel!" == "0" (       set foundin=%%i        rem exit after find first occurrence.       goto found     ) )   :notfound echo unable locate search string "%searchstr%" in specified files. goto end  :found echo found search string "%searchstr%" in "%foundin%".  :end 

edit 1 - using self contained / portable 7-zip

download official 7-zip command line version 1 listed on official 7-zip download page extract , use 7za.exe it's self-contained command line version of 7-zip, meaning won't need files 7za.exe.

you need change 2 occurrences of 7z 7za use version. line:

7z x "%%i" -so | 7z x -si -ttar -so | findstr /c:"%searchstr%" 

changes to:

7za x "%%i" -so | 7za x -si -ttar -so | findstr /c:"%searchstr%" 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -