in reply to Deleting and replacing lines in a file
#!/bin/perl -ni.bak print $. < 3 ? () : $. > 3 ? $_ : "new third\n";
Of course, it doesn't work right if you specify more than one file on the command line, but hey...#!/bin/perl -ni.bak print } BEGIN { scalar <>; scalar <>; scalar <>; print "This text replaces the third line.\n"; } {
jdporter
The 6th Rule of Perl Club is -- There is no Rule #6.
|
|---|