On Oct 11, 4:25 am, [EMAIL PROTECTED] (Jeff Pang) wrote: > 2007/10/11, PeiYu Zeng <[EMAIL PROTECTED]>: > > > Hello, > > > Can I modify the contents of a file, without creating a new one? > > Yes.You can use perl one-liner to do that, > > perl -pi.bak -e 'modify the current line if it match some conditions' file > > But actually this has been creating a new file,you just wouldn's see it.
Since you added .bak to the -i option, you'll end up with both versions, so you will see it. If you're on a *nix system, you could leave of the .bak in which case you'll end up with just the one file. For some reason, adding the ext to keep the original is required on Windows (ActiveState Perl). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/