Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting vertical list to horizontal list file???

Status
Not open for further replies.

itpmguy

Programmer
Apr 25, 2002
31
US
Hi,
I have a text file that has values listed one below the other. Ex.:

Milwaukee
Chicago
Dallas
New York

There are about 1500 values.

I want the values to appear as:

Milwaukee, Chicago, Dallas, New York

I want 10 values per line and next 10 on the next line.

Thanks


Cheap Computer Part Supply Buying Tips
VOIP Phone Service Guide
 
cat filename | paste - - - - - - - - - -

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Just for grins (replaces spaces with commas):

Code:
sed 's/ /|/g' file|xargs -n10 |sed 's/|/ /g'|sed 's/ /,/g'

Hey, it's Friday!
 
You could use sed to add a comma before doing the paste

sed 's/$/,/g' < file > newfile

then

cat newfile | paste - - - - - - - - -

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top