我有以下形式的数据:
num1 This is a string
num2 This is another string
我想限制第一个制表符之后的所有字符串的长度......这样 length(string)<4。因此,我得到的输出是:
num1 This is a string
num2 This is another
我可以使用 python 来做到这一点。但我正试图找到一个 linux 等价物以实现相同的目标。
最佳答案
在 bash 中,您可以使用以下限制字符串,在本例中,从索引 0 到索引 17。
$ var="this is a another string"
$ echo ${var:0:17}
this is a another
关于linux - 如何使用 linux 限制一行中出现的字符串的长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19869511/