Perl One Liners

Read a text file and write to another text file with line numbers in it.

[raja@AGRAJA ~]$ perl -ne  'print($.,$_)' < input_file.txt > output_file.txt

Edit file’s contents and replace text.

[raja@AGRAJA ~]$ perl -pi -e 's/old_text/new_text/' file.txt