Software Helpful Commands For Searching Archives Without Extracting
We all often deal with large archives that we might want to search without having to extract the files from it. Here are the commands that I've found most useful for each type or archive.
You could remove the
from the end to see the grep results being piped to stdout.
Some additional flags on the grep that might be useful:
HTML:
# gz
gunzip -c archive.gz | grep "search text" > out.txt
# 7z
7z e -so archive.7z | grep "search text" > out.txt
# zip
unzip -p archive.zip | grep "search text" > out.txt
# rar
unrar p archive.rar | grep "search text" > out.txt
You could remove the
HTML:
> out.txt
Some additional flags on the grep that might be useful:
HTML:
# grep which allows literal interpretations of punctuating marks like periods (whereas before, periods would be interpreted as regex parts)
grep -F "search text"
# when grep finds a match, get n number of lines above and below the match
grep -C 1 "search text"