0

I'm trying to return a sorted list of requests per OS type, parsed from an Apache access_log file (not combined format as I need the user-agent info). Here's an example of the output I'm looking for:

250 Windows NT 6.1; WOW64
200 X11; Linux x86_64

I've been able to find a partial solution, thanks to this post. Here's what I've got so far:

awk -F'"' '/GET/ {print $6}' access_log.3 | cut -d' ' -f2 | sort | uniq -c | sort -rn

Is it possible to use cut to get the strings I need, or is another method needed?

  • Can we see some sample input? – fedorqui Jan 20 '14 at 10:38
1
awk -F'"' '/GET/ {print $6}' access_log.3 | awk -F "[()]" '{print $2}' | sort | uniq -c | sort -rn
  • Excellent. This works perfectly. Knew I should have been using another awk there after the first pipe. Thanks @theofpa – Alex Jan 20 '14 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.