Replace in large text file ?

Tim Chase python.list at tim.thechases.com
Wed Jun 9 07:00:04 EDT 2010


On 06/09/2010 05:27 AM, hiral wrote:
> On Jun 6, 7:27 am, Steve<vvw... at googlemail.com>  wrote:
>> On 5 June, 08:53, Steve<vvw... at googlemail.com>  wrote:
>>> Remove all comma's
>>> Replace all @ with comma's
>>> Save as a new file.
>>
>> Many thanks for your suggestions.
>>
>> sed -i 's/Hello/hello/g' file
>>
>> Run twice on the CL..with the hello's changed for my needs did it in a
>> few minutes ,
>
> You can do...
>
> sed "s/,//g"<your_file>  | sed "s/@/,/g">  <new_file>

No need to use 2 sed processes:

   sed 's/,//g;y/@/,/' your_file > new_file

(you could use "s/@/,/g" as well, but the internal implementation 
of the transliterate "y" should be a lot faster)

-tkc






More information about the Python-list mailing list