Extract value between double quotes

awk

My query is to extract the value between double quotes "". Sample input is:

10.219.41.68 – – – [11/Jun/2014:10:23:04 -0400] Sec:0 MicSec:1797 "GET /balancer-manager HTTP/1.1" 200 28980 "-" "curl/7.15.5
(i386-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3
libidn/0.6.5"

I have large log files, so values can be vary for each line, need to extract the value between first occurrence of double quotes…

Expected output:

GET /balancer-manager HTTP/1.1

Anyone have any idea then please suggest.

Best Answer

You can just use cut for this:

$cut -d '"' -f2 < logfile
GET /balancer-manager HTTP/1.1

-d '"' tells cut to use a double quote as its field delimiter. -f2 tells it to take the second field, which is between the first and second quotes - or the first quoted string, exactly what you want.

Related Question