extract regexp result from string and write it to a variable

前端 未结 5 1458
星月不相逢
星月不相逢 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:26

    value=`cat $1 | grep -e 'set output' | cut -d'"' -f 2`
    

    using " instead of ' and the line above does the job.

提交回复
热议问题