Reputation: 2694
What am I doing wrong?
sed -i 's/** [out :: [email protected]]/machine-6/g' file1.csv
Error -: sed: -e expression #1, char 58: Invalid range end
I basically want to replace [email protected] with just machine-6 through bash?
Additionally, I want to do this for all machines (7 of them), so will I have to write this line individually for each, or can I use the same replace line for all of them?
Any help appreciated
Upvotes: 1
Views: 123
Reputation: 65851
Square brackets are special characters. When you mean them literally, you need to escape them, as well as dots:
\[out :: apple\.mango@machine-6\.mysite\.com\]
Also, if you mean the asterisks literally, it's better to escape them, as well.
And yes, you can write a loop to run through 7 machine numbers using seq
:
for i in $(seq 7); do
sed -i "s/\*\* \[out :: apple\.mango@machine-$i\.mysite\.com]/machine-$i/g" file1.csv
done
Note the double quotes I used here, as single quotes prevernt variable expansion.
Upvotes: 4