Forum Kurallarını Okumak İçin Lütfen Tıklayınız .

Helpful Commands For Searching Archives Without Extracting Software 

Software Helpful Commands For Searching Archives Without Extracting
Joined
Sep 9, 2023
Messages
16
Reaction score
34
#CR
29
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.

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
from the end to see the grep results being piped to stdout.

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"
 
between this method and extracting a large file, which would you find worth in terms of efficiency?
 

Users who are viewing this thread

Home Register
Top Bottom