Skip to main content
added 574 characters in body
Source Link
edublog
  • 93
  • 2
  • 12

I have logfiles and the lines are as follows,

2022-05-21 23:59:59,2406,842,[75000000,074],passed
2022-05-21 23:59:59,2410,841,[750000,076],passed
2022-05-21 23:59:59,3002,892,[700000,78],passed

Are there any method to grep the 75 ,70 as well? I have tried as below, but it is not working. I need the occurrences as well.

cat 20220521log|grep -E "2022-05-21 23|75" -C

Update:

Each and every log contains different timesamps and numbers as above mentioned. I need to check how many occurences can be found in each file according to my pattern. Lets take 20220521 log file I need to check in how many line contains which starts the number field as 75. All other fields are same as before.

2022-05-21 23:59:59,2406,842,[75000000,074],passed //should take as one occurence
2022-05-21 23:59:59,2406,842,[00000000,074],passed //should not consider
2022-05-21 23:59:59,2406,842,[754324000,074],passed //should take as one occurence.

I have logfiles and the lines are as follows,

2022-05-21 23:59:59,2406,842,[75000000,074],passed
2022-05-21 23:59:59,2410,841,[750000,076],passed
2022-05-21 23:59:59,3002,892,[700000,78],passed

Are there any method to grep the 75 ,70 as well? I have tried as below, but it is not working. I need the occurrences as well.

cat 20220521log|grep -E "2022-05-21 23|75" -C

I have logfiles and the lines are as follows,

2022-05-21 23:59:59,2406,842,[75000000,074],passed
2022-05-21 23:59:59,2410,841,[750000,076],passed
2022-05-21 23:59:59,3002,892,[700000,78],passed

Are there any method to grep the 75 ,70 as well? I have tried as below, but it is not working. I need the occurrences as well.

cat 20220521log|grep -E "2022-05-21 23|75" -C

Update:

Each and every log contains different timesamps and numbers as above mentioned. I need to check how many occurences can be found in each file according to my pattern. Lets take 20220521 log file I need to check in how many line contains which starts the number field as 75. All other fields are same as before.

2022-05-21 23:59:59,2406,842,[75000000,074],passed //should take as one occurence
2022-05-21 23:59:59,2406,842,[00000000,074],passed //should not consider
2022-05-21 23:59:59,2406,842,[754324000,074],passed //should take as one occurence.
Source Link
edublog
  • 93
  • 2
  • 12

How to grep with specific format and get occurrences in Linux

I have logfiles and the lines are as follows,

2022-05-21 23:59:59,2406,842,[75000000,074],passed
2022-05-21 23:59:59,2410,841,[750000,076],passed
2022-05-21 23:59:59,3002,892,[700000,78],passed

Are there any method to grep the 75 ,70 as well? I have tried as below, but it is not working. I need the occurrences as well.

cat 20220521log|grep -E "2022-05-21 23|75" -C