I am looking for two separate patterns each having a specific constraints within some large compressed files. I can't for the life of me figure out how to grep for both cases at once.
For an example, a file daily records that add up over time:
myfile
AnimalID-Type-Mood
Animal456-Dog-happy-day1
Animal453-Elephant-happy-day1
Animal896-Dog-sad-day1
Animal405-Dog-angry-day1
Animal443-Goat-angry-day1
Animal453-Dog-sad-day1
Animal473-Cat-sad-day1
Animal452-cat-happy-day1
Animal456-Dog-angry-day2
Animal453-Elephant-sad-day2
Animal896-Dog-happy-day2
Animal405-Dog-angry-day2
Animal443-Goat-happy-day2
Animal453-Dog-happy-day2
Animal473-Cat-happy-day2
Animal452-cat-happy-day2
So far I have tried
zcat.myfile | grep -e 'Dog|happy' | grep -e 'Cat|happy'
Essentially I am trying to find how many days out of the year, by AnimalID, that a dog is happy and a cat is happy. I can do counts and sorts, I just can't figure out how to run that
You can use zgrep
here:
zgrep -iE '(Dog|Cat)-happy' file
You can specify multiple pattern with the -e
option
$ seq 10 | grep -e 5 -e 6
5
6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With