如何从shell字符串中剪切最后一个字段 [英] How to cut the last field from a shell string
本文介绍了如何从shell字符串中剪切最后一个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何剪切此shell字符串中的最后一个字段
How to cut the last field in this shell string
LINE="/string/to/cut.txt"
因此字符串看起来像这样
So that the string would look like this
LINE="/string/to/"
感谢
推荐答案
我认为您可以使用 dirname命令。它输入一个文件路径,删除文件名部分并返回路径。例如:
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
这篇关于如何从shell字符串中剪切最后一个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文