I am trying to regex this single line user_agent field.
user_agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/437.38 (KHTML, like Gecko) Chrome/49.0.3477.100 Safari/437.38"
cat myfile | grep -oP '(user_agent=[^ ]*)' | awk {'print $1'}
The command above returns
“user_agent="Mozilla/5.0 “
only. However I need a whole text
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/437.38 (KHTML, like Gecko) Chrome/49.0.3477.100 Safari/437.38"
to be matched.
Please help modify the regex pattern I used.
'user_agent=[^ ].*)'
and remove the awk print. – Amit Bhardwaj'user_agent=\".*\")(?=\saccept)'
– Amit Bhardwaj