How to use sed/grep to extract text between two words?

后端 未结 12 2361
春和景丽
春和景丽 2020-11-22 05:25

I am trying to output a string that contains everything between two words of a string:

input:

\"Here is a String\"

output:

12条回答
  •  鱼传尺愫
    2020-11-22 05:49

    You can use \1 (refer to http://www.grymoire.com/Unix/Sed.html#uh-4):

    echo "Hello is a String" | sed 's/Hello\(.*\)String/\1/g'
    

    The contents that is inside the brackets will be stored as \1.

提交回复
热议问题