Sed - insert character between tag

Florian Diesch diesch at spamfence.net
Wed Dec 16 00:09:47 UTC 2009


Bruno Galindro da Costa <bruno.galindro at gmail.com> 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/>




More information about the ubuntu-users mailing list