【发布时间】:2010-10-07 14:22:30
【问题描述】:
我想知道我可以在 sed 中使用哪种模式来更改大文件 (~2 GB) 的第一行。偏爱 sed 只是因为我认为它必须比 Python 或 Perl 脚本快。
文件具有以下结构:
field 1, field 2, ... field n
data
并且,考虑到每个字段的标识符中都有空格的可能性,我需要用这种方式用下划线替换每个空格:
**BEFORE**
the first name,the second name,the first surname,a nickname, ...
data
**AFTER**
the_first_name,the_second_name,the_first_surname,a_nickname, ...
data
任何指向要使用的正确模式的指针,或其他脚本解决方案都会很棒。
【问题讨论】: