I want to parse a string for specific submatches and output those - one submatch per line - into a file.Essentially I would like to extract the value of each href-attribute:$ cat Fin<a href=a.htm>A</a>X<a href=b.htm>B</a>Y<a href=c.htm>C</a>$ echo Fin | [grep, sed, awk, ...?] > Fout$ cat Fouta.htmb.htmc.htmI tried few things with named tools but things don't work or are too complicated. I would like to perform this transformation within a single command line concatenating as few as possible commands with piping.
How to extract submatches from a string and write those to a file?
sed;grep;awk
You can use GNU grep (if built with PCRE support) for this:$ grep -Po '(?<=a href=)[^]*' filea.htmb.htmc.htmIt is a look-behind (what's after a href=?) and gets everything up to next double quote.