Need to insert new text and change existing text in a file using SED

Hi all,

I need to insert new text and change existing text in a file. For that I used the below line in the command line and got the expected output.
sed '$a\
hi...
' shell > shell1
But I face problem when using the same in script. It is throwing the error as,
sed: command garbled: $ahi...

Can anyone please help me to solve my issue??
Thanks in advance!!!
Geetha

Hi geetha,

Pls. paste your file contents here and the output required out of it.

Regards,
Vinod.

Let we take the contant of the file shell as.
12 routine
13 shell

and I need a new file shell1 with the content of shell along with the appended contant "hi..."

Try:

sed 's/shell/& hi.../' shell > shell1

We could use the following:

awk '{print $0 " hi...."}' shell > shell1

Regards,
Vinod.