bash - Extracting a word from the middle of a sentence -
i have log file this:
2013-07-10 21:40:54 [info] janus_mesca joined game 2013-07-10 21:40:54 [info] fenlig joined game 2013-07-10 21:41:21 [info] bigredhoodie joined game
i'm trying print whatever appears in between "[info]" , "joined".
with attempts i've been able remove 2 words themselves.
tail -500 $rfile | grep "info.*joined game" | \ sed -e 's/\[info\]\(.*\)joined/\1/'
can help?
pure grep version lookahead/lookbehind. p.s. option -p might not available everywhere, thought clever.
tail test.log | grep -po '(?<=\[info\] ).*(?= joined .*)'
Comments
Post a Comment