How can I extract a list of files with download counts from an Apache log

Good day! I have a standard Apache log file, and I'd like to be able to extract a list of downloaded .m4a files in a specific directory, along with a count of how many times each was downloaded. I know how to do this for a single file, with:

grep filename.txt logfile | grep " 200" | wc -l

But that just gives me a single number, and I need to know each file name ahead of time.

What I'd like to get out is a sorted list of download counts and file names something along these lines:

650 /podcasts/12323.m4a
623 /podcasts/12329.m4a
601 /podcasts/12329.m4a
432 /podcasts/11521.m4a

And so on... Thanks!

cheers... -Adam


Try with

cat access.log | awk '$9==200 { print $7 }' | sort | uniq -c | sort -n

(where the file name is in the 7th and 200 in the 9th position of the log file)

Need Your Help

Solving Numerical Integration Implicitly in Matlab

matlab integration implicit symbolic-math

I am working on constant temperature hot-wire anemometry in Matlab. So I am using a second order differential equation (conduction equation).