I have a file with following content:
[A hi] [B hello]
[A how] [A why] [C some where]
I basically want to extract the “text” with marker ‘A’ I mean
hi
how
why
in a new file on separate lines.
I tried using sed but I could not get the regular expression. Can someone suggest me what can I use ?
Try doing this using grep :
or
RESULT
EXPLANATIONS
-ofor grep stands for “get only the matching part”-Pfor grep stands for “Perl extented regex”\Kregex trick, see Support of \K in regex (it’s an advanced look-around regex trick)The same regex in perl with comments :
LINKS
To learn regex, see