• Uncategorized

About linux : Bash-sed-command-insert-between-special-characters-duplicate

Question Detail

I am quite new to Bash and sed.

I have a file named test.xml. This looks like this:

variable1=”” variable2=”” variable3=””

This is only one line of the file there is more above and under of this line.
My goal is that at the end with sed the line looks like this:

variable1=”” variable2=”123″ variable3=””

I tried with this command: sed -i 's/\bvariable2="\b/& 123/' test.xml
But this didnt work. Any ideas?

Question Answer

may be :

sed -i '' 's/variable2=""/variable2="123"/g' test.xml

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.