I would like to know which pattern can I use in sed to make changes in the first line of huge files (~2 GB). The preference for sed is only because I assume it must be faster than a Python or Perl script.

The files have the following structure:

field 1, field 2, ... field n
data

and, given the likelihood of having spaces in the identifier for every field, I need to replace every space by an underscore in this way:

**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

Any pointers to the right pattern to use, or another scripting solution would be great.

Edit
Report