我们需要使用 shell 脚本删除分隔文件中的某些字段,但我们不想松开分隔符。IE
$cat file1
col1,col2,col3,col4,col5
1234,4567,7890,9876,6754
abcd,efgh,ijkl,rtyt,cvbn
now we need to generate different file (say file2) out of file1 with second and fourth column removed with delimeter (,) intact
i.e
$cat file2
col1,,col3,,col5
1234,,7890,,6754
abcd,,ijkl,,cvbn
请提出实现这一目标的最简单和有效的方法,因为文件有大约 300 个字段/列,AWK 由于其与字段数量相关的限制而无法工作。