Solved

quick one

Posted on 2009-07-09
4
264 Views
Last Modified: 2012-05-07
I have a file with a sequence of hex numbers, one per line. I need to get them all on one line, comma delimited. I can get the comma on the end, but how do I join up all my little scalars into an array and print?

So far I have  perl -wnl -e 's/$/,/g;print' my-devs which gives me

0001,
0002,
etc...

I want 0001,0002

thanks.
0
Comment
Question by:Rowley
4 Comments
 
LVL 40

Expert Comment

by:mrjoltcola
Comment Utility
Try this?

perl -wnl -e 's/[\n\r]+/,/gm;print'
0
 
LVL 39

Accepted Solution

by:
Adam314 earned 125 total points
Comment Utility
On windows, replace single quote ' with double quote "

#If you already have the comma's, and just need to join the lines:

perl -pe 'chomp' file.txt
 

#If you need to add comma's and join the lines:

perl -pe 's/[\r\n]+/,/' file.txt

Open in new window

0
 
LVL 13

Author Closing Comment

by:Rowley
Comment Utility
spot on ta. -p - handy too. Other poster - sorry, didn't work.
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
perl -wpl -e '$\=!s/$/,/;' my-devs
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 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

15 Experts available now in Live!

Get 1:1 Help Now