I want to insert a line after a line by searching for the last occurence for that. I have taken an already posted example.
Say in the following file
adfadfadf cool aaaaaaaaaaaaaa
hai how are you
I want to insert after the red line. With unix sed command we can do it, but i think it needs an temp file. Using Perl we can do it with out using temp file. Perl onliner perl -i -ne 'print ..................' file name will help.
Can some give me the exact command
I need a perl onliner which seaches a line starting with a pattern(last occurence) and display it.
grep 'pattern' filename | tail -1 in UNIX
Ex: I want to display the line starting with "cool" and which is a last occurence
cool dfadfadfadfara... (4 Replies)