How to remove the last character from a bash grep output

后端 未结 14 1587
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-08 06:29
COMPANY_NAME=`cat file.txt | grep \"company_name\" | cut -d \'=\' -f 2` 

outputs something like this

\"Abc Inc\";

14条回答
  •  长情又很酷
    2020-12-08 06:53

    Assuming the quotation marks are actually part of the output, couldn't you just use the -o switch to return everything between the quote marks?

    COMPANY_NAME="\"ABC Inc\";" | echo $COMPANY_NAME | grep -o "\"*.*\""
    

提交回复
热议问题