Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

substitute text after particular line: line number not known

6 views
Skip to first unread message

Nagrik

unread,
Sep 12, 2010, 2:56:24 PM9/12/10
to
Hello Group,

I have a variable name defined as HOSTIP=10.10.10.10, so

echo $HOSTIP

prints 10.10.10.10

I have a system file sshd_cnfg, and at some place it has lines

#ListenAddress 0.0.0.0
#ListenAddress ::

I want to INSERT text

ListenAddress $HOSTIP:22

after the last line containing #ListenAddress, i.e. after

#ListenAddress ::

so that after insertion the sshd_cnfg file will read

#ListenAddress 0.0.0.0
#ListenAddress ::
ListenAddress 10.10.10.10:22

at that place.

I have tried very many combinations of "sed" command, but with no
success.

I don't know the line number of any line in sshd_cnfg file.

Can someone please tell me the exact syntex involving "sed."

Thanks in anticipation. I will greatly appreciate this help.

nagrik

0 new messages