query on count

gudii9
gudii9 used Ask the Experts™
on
zgrep 'XYZ|AB|MASTER' AAAA.log.20180904.gz | grep '|[1-9][0-9][0-9][0-9][0-9]|0000' | wc -l

can you please advise what is the meaning of above zgrep command

where i can find, practice and learn above kind of commands

how grep and egrep are different

https://ryanstutorials.net/linuxtutorial/grep.php
how to learn regular expressions used in queries

Please advise
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017
Commented:
zgrep has the same behavior as grep with z representing that it is searching within a compressed archive.

First it looks for a combination of patterns with | representing a logical or

I would suggest to understand, it is best to see what the output of the zgrep.
zgrep 'XYZ|AB|MASTER' AAAA.log.20180904.gz | head -10
The above will show you the first 10 lines of data.

Then try
zgrep 'XYZ|AB|MASTER' AAAA.log.20180904.gz | grep '|[1-9][0-9][0-9][0-9][0-9]|0000' | head -50

The pattern in second [1-9] means a litteral match to a number from 1 to 9
When staggered as in this example it looks for abcde that can be from 10000-99999 or 0000
It looks for matches of an earlier scan, that includes a number in that range or 0000
It then counts the number of occurances.
Rahul ShendeJr. Linux System Administrator
Commented:

Author

Commented:
grep '|[1-9][0-9][0-9][0-9][0-9]|0000' | wc -l

does it find transactions taking more than 20 seconds?

how to make to find transactions taking more than 30 seconds

how to make to find transactions taking more than 50 seconds

how to make query to nd transactions taking more than 60 seconds between 11:43 to 22:15 on 09/05/2018
please advise
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
how awk different from regular expression?
Distinguished Expert 2017

Commented:
the above is looking for a pattern of numbers,
you have to post the line that is returned to determine what it means.

AWK is a text processor it can use a regular expression,

awk -F ' (check condition) { print } ' filename

post a line from the log
(though you currently use a compressed archive as the starting point.)

then ask your question based on the information

regualr expressions are a way to search for patterns rather than specific words..

awk is command similar to cut while regular expression is implemented in many different environments
i.e. [0-9] means search for a number between 0 and 9

there are many resources. I find it best to learn when I need something done.

versus learning in the abstract.

Author

Commented:
the above is looking for a pattern of numbers,
you have to post the line that is returned to determine what it means.

it reurned
142


which means number of transactions 142 taking more than 30 seconds

Author

Commented:
any good video tutorials around these topics to understand deeply and better?
Distinguished Expert 2017

Commented:
the output of wc -l return a line number count.

To address your question on regular expression one needs to see the input which are the actual lines
i.e. the output of zgrep
then the output of the earlier line passed though  grep.

based on these sets of data we can answer whether the end count which in the snapshot is 142 means that there were 142 instances that took longer than 20 seconds, it might appear so, but it might not be the basis on which the current basis of information.

https://www.shortcutfoo.com/app/dojos/regex/cheatsheet
https://www.rexegg.com/regex-quickstart.html

these are no uniformly implemented in terms of if you use perl the reg ex might deviate slightly. tcl/tk
sql, etc.

I've seen complex variation where you can span multiple lines or get data through the query spannning multiple lines...


use what you have
run the first command and see the output.
run the first passing

Explore the data you have as I suggested so that you can see what the zgrep command does and its results.
Then run the first passing the data to the grep secodary command and then see what it shows.

......

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial