( categories: one liners )
For example, insert the line "New line added!!" in line 100 of example.txt:
perl -pi -le 'print "New line added!!" if $. == 100' example.txt
If you want to insert the same line in multiple files, use the following:
perl -pi -le 'print "New line added!!" if $. == 100; close ARGV if eof' *.txt
('close ARGV if eof' is needed to reset the variable '$.' before processing the next file).





