Re: Sed - insert character between tag



Bruno Galindro da Costa <bruno.galindro@xxxxxxxxx> writes:

Hi all!

I have a text file with this content:

VAR_1="xyz "abcd" fgh"

Using sed, how can I insert a backslash before the two quotes between the
first and last quote?

e.g.: VAR_1="xyz \"abcd\" fgh"

sed -r 's/"/\\"/g;s/\\"/"/;s/(.*)\\"/\1"/'

Maybe there's something more elegant...


Florian
--
<http://www.florian-diesch.de/software/shell-scripts/>

--
ubuntu-users mailing list
ubuntu-users@xxxxxxxxxxxxxxxx
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users