我正在使用下面的命令清空列,但我想保留标题行,如何在同一命令中执行此操作?
awk -F "," '{$10="";}1' OFS="," InputFile.csv > test.csv
答案1
您可以通过以下方式实现:
awk -F, 'NR != 1{$10=""}1' OFS=, InputFile.csv > test.csv
这将跳过第一行的任何操作。
答案2
$ sed -e 's/[^,]*//10' input.file
将使输入文件中的第 10 个字段为空。
答案3
I Done by below method tested and it worked fine too
awk -F "," 'NR >1{$10="";}1' OFS="," InputFile.csv > test.csv
Tested and it worked fine too