我有一个包含以下内容的 file1:
1,joe,jim,bob,sally,mark,sue,etc,etc
2,julie,barbra,joe,jim,bob,sally,mark,sue,etc,etc
1,clarie,mike,joe,jim,bob,sally,,etc,etc
2,matt,alivia,joe,jim,bob,mark,sue,etc,etc
1,julie,claire,joe,jim,bob,sally,mark,sue,etc,etc
2,sophia,joe,jim,bob,sally,mark,sue,etc,etc
我想更改它,使第 1 列按数字顺序排列并写入 file2:
1,joe,jim,bob,sally,mark,sue,etc,etc
2,julie,barbra,joe,jim,bob,sally,mark,sue,etc,etc
3,clarie,mike,joe,jim,bob,sally,,etc,etc
4,matt,alivia,joe,jim,bob,mark,sue,etc,etc
5,julie,claire,joe,jim,bob,sally,mark,sue,etc,etc
6,sophia,joe,jim,bob,sally,mark,sue,etc,etc
我的 file1 有超过 100,000 行,每行有 65-90 列。
答案1
假设没有转义逗号,可能的解决方案:
awk 'BEGIN { OFS=FS="," } { $1=NR; print }' input.csv > output.csv