Skip to main content

Extract all paths from a logfile

awk '{gsub(/"/,"",$7); print $7}' access.log

This line extracts all paths from an apache logfile, change number 7 if your logfile line has another format than ours

Other way, to get each path only once, if HTTP Status code is 200 is:

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

This one checks if the path contains 'api':

cat access.log | awk '(index($7, "api") != 0) { print $7 }' | sort | uniq -c | sort -n