sed can do it. The trick is to deal with the 'c' so that sed doesn't remove it entirely until the new 'c' are added in. That's the point of the '%' in the first and last clauses of the script. I'm assuming that the leading digits in your example are line numbers and should never be changed. That allowed me to pay attention to leading white space in each token.
Here's my one liner:
sed -e 's/c\([^ ]*\)/%\1/g' -e 's/ \([^%][^ ]*\)/ c\1/g' -e 's/%//g' < $infile > %outfile
griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256