You do not even need the template /trade_id_external/
before s///
$ sed -n 's/.*trade_id_external="\([^"]*\).*/\1/p' file 001-002141880445/5862
Basic sed \(...\)
refers to capture groups that were used to capture the characters you want to print in the final.
Via grep ,
$ grep -oP 'trade_id_external="\K[^"]*' file 001-002141880445/5862
-P
will enable perl-regex mode in grep. Therefore, we could use any PCRE regular expression in grep with the -P
option. \K
in the above regular expression will cancel previously matched characters, that is, it will not consider characters that match the pattern, exists before \K
source share