删除csv文件的第一列

删除csv文件的第一列

This question already has answers here:
awk - how to delete first column with field separator

(5个答案)


3年前关闭。




我想知道如何使用awk或sed删除csv文件的第一列

像这样的东西:
FIRST,SECOND,THIRD

对于这样的事情
SECOND,THIRD

提前致谢

最佳答案

跟随awk将同样为您提供帮助。

awk '{sub(/[^,]*/,"");sub(/,/,"")} 1'   Input_file

遵循sed可能也可以帮助您。
sed 's/\([^,]*\),\(.*\)/\2/'  Input_file

说明:
awk '                 ##Starting awk code here.
{
  sub(/[^,]*/,"")     ##Using sub for substituting everything till 1st occurence of comma(,) with NULL.
  sub(/,/,"")         ##Using sub for substituting comma with NULL in current line.
}
1                     ##Mentioning 1 will print edited/non-edited lines here.
'   Input_file        ##Mentioning Input_file name here.

关于bash - 删除csv文件的第一列,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46904805/

10-11 15:39