"Inserting" a line in a text file?

Gustavo Cordova gcordova at hebmex.com
Tue May 7 16:44:19 EDT 2002


> 
> rename tgtfile tempfile              # very fast
> cat 'new single line' >  tgtfile    # very fast
> cat tempfile >> tgtfile                # the slow step
> del tempfile                               # very fast
> 
> Raymond Hettinger
> 

Another way would be:

$ echo "single line stuff" > endfile.txt
$ mysqldump xxx xxx xxx >> endfile.txt

no need to be renaming and stuff.

>From python it's about the same.

-gustavo





More information about the Python-list mailing list