We help IT Professionals succeed at work.

query on count

190 Views
Last Modified: 2019-01-10
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

CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Rahul ShendeJr. Linux System Administrator
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

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

Author

Commented:
how awk different from regular expression?
CERTIFIED EXPERT
Distinguished Expert 2019

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?
CERTIFIED EXPERT
Distinguished Expert 2019

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.

......