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



Relevant Pages

  • Re: Sed - insert character between tag
    ... how can I insert a backslash before the two quotes between ... Bruno Galindro da Costa ... Jozsef Kurucity | Web & Graphic Designer ...
    (Ubuntu)
  • Re: Sed - insert character between tag
    ... Work´s perfectly Florian! ... how can I insert a backslash before the two quotes between the ... Bruno Galindro da Costa ...
    (Ubuntu)
  • Sed - insert character between tag
    ... how can I insert a backslash before the two quotes between the ... Bruno Galindro da Costa ...
    (Ubuntu)
  • Re: inserting in regular expressions
    ... for re.sub says "repl can be a string or a function; ... When python compiles/interprets a quote literal, the syntax parsing has to decide where the literal stops, so quotes are treated specially. ... But the more general way to put funny characters into a quote literal is to escape each with a backslash. ...
    (comp.lang.python)
  • Re: regex help
    ... I have a few regexs I need to do, but im struggling to come up with a ... The obvious problems here are the spurious double quotes, ... backslash and open parenthesis. ... literals when you're dealing with regular expressions, ...
    (comp.lang.python)