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/ replace old with new
  • [^_]+ some characters that are not underscore
  • (some chars) save some 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