Solved

quick awk/sed question: how to add characters in a line

Posted on 2014-02-11
2
340 Views
Last Modified: 2014-02-11
Have many long lines like the following:

(AA 10, (xxx-xx-xxx) BB, 200 A)
(Test 20, (YYY-YY-YYY) DCB, 100000 BBB)
....

How to add a comma to the positions which do not have?
Expected output is
(AA, 10, (xxx-xx-xxx), BB, 200, A)
(Test, 20, (YYY-YY-YYY), DCB, 100000, BBB)
...

Preferred awk/sed, but perl is OK too.
Thanks in advance.
0
Comment
Question by:jl66
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 39850704
sed 's/\([^ ,]\) /\1, /g'  <<END
(AA 10, (xxx-xx-xxx) BB, 200 A)
(Test 20, (YYY-YY-YYY) DCB, 100000 BBB)
END
0
 

Author Closing Comment

by:jl66
ID: 39851005
ozo, you have always been helpful. I really appreciate.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now