Thanks, Both the following work as I need. I am sure I will get a chance to play with them more over the next few weeks. sed -e '/ServerName /{' -e h -e 's/ServerName \(.*\)/ServerAlias www.\1/' -e x -e G -e '}' test sed 's/^\(ServerName \(.*\)\)$/\1\nServerAlias www.\2/' test Thanks All, -- Jim Seymour