I want to grep STX= ....... until its first delimiter ' and IRF= ..... until its first delimiter '.
Like:
:STX=ANAA:1+asdf+5060128703127:P' IRF=16165193117+160624+160624 ' 11 Answer
Thanks to @terdon and @jhilmer for making the quoting decidedly less tricky
If you want the '
$ grep -oE "(STX|IRF).*'" file STX=ANAA:1+asdf+5060128703127:P' IRF=16165193117+160624+160624 ' If you don't want the '
$ grep -oE "(STX|IRF)[^']*" STX=ANAA:1+asdf+5060128703127:P IRF=16165193117+160624+160624 Explanation
-ojust show the matched part-Euse ERE so we can use|to search for multiple patterns"start quoting/stop quoting(THIS|THAT)matchTHISorTHAT.*match any number of any characters\'literal'[^']*any number of any characters except'