我想知道我可以在sed中使用哪种模式来更改巨大文件的第一行(~2 GB).对sed的偏好只是因为我认为它必须比Python或Perl脚本更快.
这些文件具有以下结构:
field 1, field 2, ... field n
data
Run Code Online (Sandbox Code Playgroud)
并且,考虑到每个字段的标识符中都有空格的可能性,我需要用这种方式用下划线替换每个空格:
**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
Run Code Online (Sandbox Code Playgroud)
任何指向正确模式的指针,或其他脚本解决方案都会很棒.