How to cut the last field from a shell string

前端 未结 5 987
孤独总比滥情好
孤独总比滥情好 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:14

    I think you could use the "dirname" command. It takes in input a file path, removes the filename part and returns the path. For example:

    $ dirname "/string/to/cut.txt"
    /string/to
    

提交回复
热议问题