【发布时间】:2013-12-09 14:38:43
【问题描述】:
我需要用序列号列表替换第一列数字。该文件如下所示:
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 相比可能但非常繁重