regex - Grepping for a pattern followed by another pattern and excluding what lies inbetween as ouput -
i want
egrep -o '(mon|tues)[1-3]?[0-9].*(mon|tues)[1-3]?[0-9]'
and isn't found (mon|tues)[1-3]?[0-9]
with input
mon19hellotues20 mon19world hellomon19 tues8worldtues22
i want
mon19tues20 tues8tues22
as output
sed
better tool print matched txt in output:
sed -ne 's/(mon|tues)([1-3]{0,1}[0-9]).*(mon|tues)([1-3]{0,1}[0-9])/\1\2\3\4/p' file mon19tues20 tues8tues22
Comments
Post a Comment