Unix,使用awk删除第一列 [英] Unix , Delete first column using awk
本文介绍了Unix,使用awk删除第一列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个名为test.txt的文件,其中包含以下内容 123,2,1
我想打印不带"123"的文件内容,
我用了以下 awk -F,'{print substr($ 0,index($ 0,$ 2))} text.txt'
I have a file named test.txt which has the following content
123,2,1
I want to print the contents of the file without "123,"
I used the following
awk -F, '{print substr($0, index($0, $2))} text.txt'
它无法正常工作,会显示 23,2,1
但是当我为文本'123,5,1'运行它时,它可以正常工作(打印 5,1
)
It doesn't work properly tho, it prints 23,2,1
But when I run it for this text '123,5,1' , it works without a problem (it prints 5,1
)
推荐答案
使用 cut
:
cut -d, -f2- file
-d,
使用,
作为分隔符,并且 -f2-
将字段2打印到最后.
-d,
uses ,
as delimiter, and -f2-
prints fields 2 to last.
这篇关于Unix,使用awk删除第一列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文