How to cut the last field from a shell string

前端 未结 5 901
孤独总比滥情好
孤独总比滥情好 2020-12-14 07:43

How to cut the last field in this shell string

LINE=\"/string/to/cut.txt\"

So that the string would look like this

LINE=\"/         


        
5条回答
  •  囚心锁ツ
    2020-12-14 08:18

    For what it's worth, a cut-based solution:

    NEW_LINE="`echo "$LINE" | rev | cut -d/ -f2- | rev`/"
    

提交回复
热议问题