I have a list that looks like this:
server
server.apple.com
server.apple.com
server
server.apple.com
Now, I would like to add “.apple.com” to the lines that says just “server”. I’ve tried sed with:
sed -e 's/\bserver\b/server.apple.com/g'
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could use:
^means start of line and$means end of the line.You also don’t need the
-eargument, as this is just basic regex.If you want case insensitive search for
server(also matchSERVERandSErvEr) you can use theIfunction, however it is not supported by various versions ofsed:If you don’t have a
sedversion that supportsIyou can use: