in reply to Writing and modifying (change ordelete) a file
The slightly longer answer is that you can modify files in place, but you can't alter the length of the file at all.
Of course, Perl makes rewriting the whole file really easy, especially with the -i and -p command-line switches. Something like the following might do what you want:
perl -i -pe 's/(user):.*?:/$1:passwd:/' filename
|
---|