Searching line by line text between first two matches
$ sed -r 's/[^_]+_([^_]+)_.*/\1/' file
ASSET-D
STRING-H
FILE-FD
Explanation
-
-r
Use ERE -
s/old/new/
replaceold
withnew
-
[^_]+
some characters that are not underscore -
(some chars)
savesome chars
for later -
.*
any number of any characters -
\1
the saved pattern
You can use awk
with the following parameters:
-
-F "_"
- which uses_
as separator -
'{print $2}'
- which prints the 2nd element$ awk -F "_" '{print $2}' input_file ASSET-D STRING-H FILE-FD