How to remove the last character from a bash grep output

后端 未结 14 1571
爱一瞬间的悲伤
爱一瞬间的悲伤 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:58

    Some refinements to answer above. To remove more than one char you add multiple question marks. For example, to remove last two chars from variable $SRC_IP_MSG, you can use:

    SRC_IP_MSG=${SRC_IP_MSG%??}
    

提交回复
热议问题