perl - appending a line after there is match for 2 pattern in Unix shell scripting -


i have file like

nithin shetty sachin shetty pavan shetty 

in file want append "hello me",next line pattern "shetty". condition if line matches "nithin" , don't append line. know how append line after pattern match,

sed '/shetty/a\   hello me ' filename` 

but in don't want line containing nithin. output should this:

nithin shetty sachin shetty   hello me pavan shetty   hello me 

is possible??

a sed solution of form:

sed '/nithin/b; /shetty/a\ hello me' filename 

b cause sed branch end of script in absence of label.


Comments