extract regexp result from string and write it to a variable

前端 未结 5 1519
星月不相逢
星月不相逢 2021-01-24 19:05

I\'m trying to write a shell script that searches in a file specified as argument $1 for a regex and writes the found subpattern into a variable I can then use.

let\'s s

5条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-24 19:19

    variable=$(sed -n '/^set output/ s/[^\x27]*\x27\([^\x27]*\)\x27/\1/p' "$1")
    

提交回复
热议问题