1

I'm trying to replace all spaces in a text with the HTML space.

cat test.txt | sed -e 's/ / /g'

But it returs without the & sign.

This nbsp;is nbsp;a nbsp;sample nbsp;text.

How do I make this right?

6
sed -e 's/ /\ /g'

Note the \ before the &. Escape your characters.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.