DEAR PEOPLE FROM THE FUTURE: Here's what we've figured out so far...

Welcome! This is a Q&A website for computer programmers and users alike, focused on helping fellow programmers and users. Read more

What are you stuck on? Ask a question and hopefully somebody will be able to help you out!
+2 votes
sed -i 's/& /& /g' *

I need to replace all the "& " with "& ", but sed is adding an additional space "& amp; ". Why is that and how can I replace the ampersand with sed?

by

1 Answer

+1 vote
 
Best answer

Have you escaped the &, as it is a Bash operator?

sed 's/\& /\& /g'

Seems to give the correct result.

by
selected by
0

This works but the & is inside quotes. Why does it need escaping if it's already quoted?

Contributions licensed under CC0
...