Solved

quick one

Posted on 2009-07-09
4
273 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
ID: 24813711
Try this?

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

Accepted Solution

by:
Adam314 earned 125 total points
ID: 24814102
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
ID: 31601591
spot on ta. -p - handy too. Other poster - sorry, didn't work.
0
 
LVL 84

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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