The data looks like this :
There is stuff here (word, word number phrases)
(word number anything, word phrases), even more
...
There is a l
Using awk
$ awk -v FS="" -v OFS="" '{ c=0; for(i=1; i<=NF; i++){ if( $i=="(" || $i ==")" ) c=1-c; if(c==1 && $i==",") $i=":" } }1' file
There is stuff here (word: word number phrases)
(word number anything: word phrases), even more
-v FS="" -v OFS=""
Set FS
to null so that each char is treated as a field.
set variable c=0
. Iterate over each field using for
loop and toggle the value of c
if (
or )
is encountered.
if c==1
and ,
appears then replace it to :