Date: Thu, 21 Jul 2016 08:00:44 -0400 From: bruce badouglas@gmail.com Subject: sed question
Hey guys..
Sed question.. should be simple, but after stack/net searches, lots or trials.. can't seem to get it..
I've got a case
any thoughts on how to handle the parens would be cool!
just irks me that I couldn't see what I missed.
You cannot 'escape' the parens since '(' and ')' are defined 'codes' like ^ & and $.
( marks the start of an internal variable to be recorded, and ) marks the end, substitution in the output side uses \1 (or \2,\3, or as many as needed)
So sed -i -e "s#('txt')#'(/dir/txt)'#g" foo
should work.
NOTE: 1) sed inplace replacement 2) using extended grep 3) for clarity, the usual use of '/' for the 's' replacement is changed to '#' 4) the global replacement marker, usually ', is changed to "
sed gets confused when dealing with mixed ' and " markers, I suspect that this is your problem. So use the opposite marker outside the sed replacement, when you have one inside.