I want to search each record (records are defined by blank lines) in a file for the pattern NAME#AAAA. If it matches, then insert an # in front of the record's AGE line and move that line to the top of the paragraph. Then insert the line AGE NIL at the end:Note : NAME#AAAA is a variable.printf %s\n 'g/NAME#AAAA/ /AGE/t- | s/^/#/ | /AGE/s/.*/AGE NIL/' x | ex input.txthow to modify this in the way it searches for $lineprintf %s\n 'g/$line/ /AGE/t- | s/^/#/ | /AGE/s/.*/AGE NIL/' x | ex input.txt is not working
search insert and replace
shell;perl;ksh;aix