grep

Regular expressions

Regular expressions

Look behind

Given the following file:

hello how are you
i am fine
let's go, you!
let's go, baby!

grep with look-behind allows to print only some parts:

$ grep -Po "(?<=let's go, ).*" file
you!
baby!

In this case, it matches what occurs after “let’s go, “.


This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow