我需要用連續數字列表替換第一列數字。該文件看起來像:Bash:用連續列表替換列中的數字列表
1 the quick brown fox jumps over
7 the lazy dog the quick brown
13 fox jumps over the lazy dog
26 the quick brown fox jumps over
31 the lazy dog the quick brown
,我需要:
1 the quick brown fox jumps over
2 the lazy dog the quick brown
3 fox jumps over the lazy dog
4 the quick brown fox jumps over
5 the lazy dog the quick brown
使用bash/SED/AWK的任何解決方案,將不勝感激。
Sed不是最好的工具,因爲內部處理的湖泊除了用其他方式取代(不計數,...)。與簡單的命令相比awk可能但非常重要 – NeronLeVelu