Questions tagged [zgrep]

zgrep is a linux command that searches gzipped files for a regular expression. Use this tag for questions related to the zgrep command.

zgrep is a linux command for performing grep on gzip compressed files. In other words you can use zgrep to search compressed files for a regular expression.

32 questions
7
votes
1 answer

Grep resource usage

I have been tasked with writing a shell script to grep through hundreds of log files in many directories on Linux and Solaris servers. Some of the logs are compressed in many formats and some are a few GB in size. I am worried about grep using a lot…
Robben
  • 83
  • 4
3
votes
1 answer

How to use zgrep and regular expression?

I'm trying to do some research in a .gz file so I found out I should use zcat / zgrep now after a bit of research I can't figure out how to use a regex with zgrep I tried to do it like this zgrep '[\s\S]{10,}' a.gz but nothing comes out even if…
J.erome
  • 688
  • 7
  • 26
2
votes
1 answer

How do I use zgrep to look for content in archived files matching a given filename pattern?

Suppose I have two tar.gz files a1.tar.gz a2.tar.gz and each archive contains many files, including a file called target.txt How do I search for BLAH in target.txt in both of these archives using zgrep without searching all of the other files in…
Graeme Moss
  • 7,995
  • 4
  • 29
  • 42
2
votes
2 answers

Get all occurrences of a string within a directory(including subdirectories) in .gz file using bash?

I want to find all the occurrences of "getId" inside a directory which has subdirectories as follows: */*/*/*/*/*/myfile.gz i tried thisfind -name *myfile.gz -print0 | xargs -0 zgrep -i "getId" but it didn't work. Can anyone tell me the best and…
user6438693
1
vote
2 answers

zgrep files in ascending order

I want to extract info from linux logs which are compressed in files numbered from file.gz to file.50.gz. Then the first log file zgrep checks is log.1.gz, then log.10.gz, then log.11.gz, etc. But this messes up with the chronology of the events. Is…
Cacu
  • 11
  • 2
1
vote
1 answer

I am a microbiologist and new to PowerShell and I have to create a script using zgrep -u

I have a folder of fastq file (genomic sequences) and an excel file with barcodes (series of 20 nucleotides) and I want to search all the barcodes in all fastq files and get the exact matches. I did "zgrep -u barcode file1 file2 file3" …
1
vote
0 answers

zipgrep with wildcard to match multiple files

How to unzip multiple zip archives using a wildcard with zipgrep: $ zipgrep statistics.*.zip caution: filename not matched: statistics.2021-02-19.1.log.zip caution: filename not matched: statistics.2021-02-19.2.log.zip caution: filename not…
Sergei Rodionov
  • 4,079
  • 6
  • 27
  • 44
1
vote
1 answer

ZGrep for first occurence of pattern *after* given line

so I know that to find the line number of the first occurrence of a pattern in a file I do: zgrep -n -m 1 "pattern" big_file.txt.gz but what If I want to skip the first 500K lines? (I can't decompress the file. It's too large.)
user189035
  • 5,589
  • 13
  • 52
  • 112
1
vote
2 answers

How to get frequency of logging using bash if each line contains a timestamp?

I have a program that during it's operation it writes to a text file. In this text file each line consists of 4 parts. Thread ID (a number) A date in the format yyyy-mm-dd A timestamp in the format 12:34:56.123456 A function name Some useful…
Muhamad Gafar
  • 409
  • 3
  • 12
1
vote
1 answer

Linux: zgrep multiple strings in one line from a tar.gz file

I have a tar.gz file (named as logs.tar.gz) which contains thousands of pieces of information, like this one shown below: 2020-06-07 09:02:14.983…
McFly
  • 27
  • 6
1
vote
1 answer

How to use zgrep to display all words of a x size from a wordlist?

I want to display all the words from my wordlist who start with a w and are 9 letters long. Yesterday I learnt a bit more on how to use zgrep so I came with : zgrep '\(^w\)\(^.........$\)' a.gz But this doesn't work and I think it's because I don't…
J.erome
  • 688
  • 7
  • 26
1
vote
1 answer

How can I specify a regex in a zgrep/zcat command?

I want to find in a list of words, every words with a least 3 times the same letter in it. To achieve that I did .*(\w).*\1.*\1.*\1.* and you can test it here http://www.regexplanet.com/advanced/java/index.html but I don't know how to put it in my…
J.erome
  • 688
  • 7
  • 26
1
vote
2 answers

An efficient search for IP addresses using Regular Expressions

I would like to find the most efficient regular expression to find three IP addresses in one search, but I'm not sure if there is a more efficient (faster) syntax that I could use. I've tried searching for them one address at a time, but I'm curious…
crosser
  • 11
  • 1
1
vote
0 answers

using zgrep to find phone numbers in a directory

I need to create a script that will search for US phone numbers in files that are in a directory that has been passed in as a parameter to your script. The script must recognize phone numbers in the following formats: (570)555-1212, 570.555.1212,…
Riderine
  • 11
  • 2
0
votes
0 answers

How to zgrep a specific key:value from .json.gz file

I have a bunch of logs in multiples .json.gz files. I can easily get a specific string with: zgrep "Search This String" * But now I need to find a specific value inside a key/attribute. I tried the following code to get a email domain from sender…
PlayHardGoPro
  • 2,791
  • 10
  • 51
  • 90
1
2 3