You can simply do whatever you want with test in ed/
sed/awk etc.
Notice that, you can edit content of file during reading it and forward output from it to other file and after that simple overwrite it e.g. in awk:
Code:
awk 'some_code' some_file > new_file; mv new_file some_file
Or use ed like it:
Code:
ed file <<-ENDIT
g/nrumber_of_line/a/some_new_text/
w
q
ENDIT
depends from your expectations.