Hi I have a file and want to replace all & amp;
with &
using sed. Can you tell me how to use sed for this, as the following command did not worked for me.
sed 's/& amp;/&/g' BX-Books.csv > r1.txt
Here & and amp have no space between.
The Linux sed command is most commonly used for substituting text. It searches for the specified pattern in a file and replaces it with the wanted string. To replace text using sed , use the substitute command s and delimiters (in most cases, slashes - / ) for separating text fields.
For replacing a variable value using sed, we first need to understand how sed works and how we can replace a simple string in any file using sed. In this syntax, you just need to provide the string you want to replace at the old string and then the new string in the inverted commas.
Based on the title of the question, you need to escape &
:
sed 's/\&/\&/g' BX-Books.csv > r1.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With