• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

quick one

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
Rowley
Asked:
Rowley
1 Solution
 
mrjoltcolaCommented:
Try this?

perl -wnl -e 's/[\n\r]+/,/gm;print'
0
 
Adam314Commented:
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
 
RowleyAuthor Commented:
spot on ta. -p - handy too. Other poster - sorry, didn't work.
0
 
ozoCommented:
perl -wpl -e '$\=!s/$/,/;' my-devs
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now