Issue
127.0.0.1 - frank [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326
How do i output the status code using the above code snippet, I tried using the cut command but there seems to be some problem
Solution
If you use awk you can do one of two things: if you assume the status is always the 9th field (remember it tokenizes using spaces by default)
awk '{print $9}'
or if you assume it is always the second to last field (as @anubhave mentioned in comments):
awk '{print $(NF-1)}'
If you prefer sed
sed -n 's/.*GET [^ ]* HTTP[^ ]*" \([0-9]\{3\}\) .*/\1/p'
Answered By - Rob