Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Can we see some sample input? –  fedorqui Jan 20 at 10:38

1 Answer 1

up vote 1 down vote accepted
awk -F'"' '/GET/ {print $6}' access_log.3 | awk -F "[()]" '{print $2}' | sort | uniq -c | sort -rn
share|improve this answer
    
Excellent. This works perfectly. Knew I should have been using another awk there after the first pipe. Thanks @theofpa –  starkiller Jan 20 at 16:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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