I try to get the hits on an access_log by hour, but inside I have some lines that I want to ignore (css/js/etc…)
If I run:
grep "31/Mar" access_log | cut -d[ -f2 | cut -d] -f1 | awk -F: '{print $2}' | sort -n | uniq -c
Have the expected result, like:
105 03 177 04 153 05 144 06
But if I add the filter :
grep "31/Mar" access_log | cut -d[ -f2 | cut -d] -f1 | awk -F '!/.pdf|.css|.png|.jpg|.js/': '{print $2}' | sort -n | uniq -c
The result is one line…
7496
What I doing wrong ?
3
Answers
My error... After tests, I notice the problem was grep. If I refine grep I can ignore lines and apply awk under the result correctly.
You probably meant to write:
but there’s other issues in your script we could help you with given a MCVE.
All this long pipeline can be done in a single
awk
as well like this: