On 7/21/2016 8:26 AM, bruce wrote:
Hey Tudor, and others..
The test sed I posted works for doing a search/replace of the text
inside the parens...
> foo('txt')
> foo("txt")
however.. if i wanted to craft a sed that uses the entire
>>foo('txt')<< as the search.. then I run into the need to handle the
parens.. and that's the issue..
this doesn't work
sed -i 's/foo('txt')/foo('/dir1/txt') /' *files.dat
sed -i 's/foo\('txt'\)/foo\('/dir1/txt'\)/' *files.dat
If you swap out the apostrophes with quotation marks it should work -
Bash is what I think is getting in your way. On Fedora 23 I have the
following in a text file called test.txt:
The 'test' case for changing foo('txt') to foo("txt") without changing
bar('txt') to bar("txt") example.
I used the following sed command:
sed -e "s/foo('txt')/foo(\"txt\")/g" test.txt
This is the output:
The 'test' case for changing foo("txt") to foo("txt") without changing
bar('txt') to bar("txt") example.
Tom
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://lists.fedoraproject.org/admin/lists/users@lists.fedoraproject.org
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org