Question : Sed help

Hello,

I have got a file pattern like below:

#cat test
PermitRootLogin yes  
#PermitRootLogin yes
PermitRootLogin no  # some text
PermitRootLogin    some text
##PermitRootLogin yes

I need a Sed command that will replace all the lines "PermitRootLogin" entries into following format:

PermitRootLogin no  
PermitRootLogin no  
PermitRootLogin no  
PermitRootLogin no  
PermitRootLogin no  

I tried with the following but it not working fully,
sed 's/PermitRootLogin.*$/PermitRootLogin no/' test

Please let me know. Thanks !

Answer : Sed help

sed -e 's/^.*PermitRootLogin.*$/PermitRootLogin\ no/g' file > file.new
Random Solutions  
 
programming4us programming4us