I'm struggling with the following:
Current File:
text1,text2,add(a,b),text3
Target File:
text1,text2,a b c,text3
where a and b vary.
Example:
text1,text2,add(11,12),text3
text1,text2,add(41,42),text3
would become:
text1,text2,11 12 c,text3
text1,text2,41 42 c,text3
I would like to do something like:
sed -i "s/add(*,*)/ a b c/g"
But I'm pretty sure the use of wildcards is completely wrong.
New to bash scripting, any advice is appreciated. Thanks.
Edit: To clarify, I want to save a and b into variables so that I can print them again.
$a
and$b
? Do you want to replace the content ofadd(a,b)
with$a $b c
where$a
is the content of a shell variable nameda
(ditob
)?$ echo 'text1,text2,add(foo,bar),text3' | sed 's/add(\([^(),]\+\),\([^,()]\+\))/\1 \2 c/'