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!

Join lines of a text file so that data is comma delimited

Status
Not open for further replies.

buckpasser

Technical User
Mar 10, 2005
24
US
I have a large text file where I want to join every 1435 lines together seperating each field with a comma.

Input looks like this:
=======================Input==================

"Record1 Field1"
"Record1 Field2"
|
|
"Record1 Field1435"
"Record2 Field1"
"Record2 Field2"
|
|
"Record2 Field1435"
"RecordN Field1"
"RecordN Field2"
|
|
"RecordN Field1"
"RecordN Field2"
|
|
"RecordN Field1435"

======================Output=====================

"Record1 Field1","Record1 Field2",--->"Record1 Field1435
"Record2 Field1","Record2 Field2",--->"Record2 Field1435
"RecordN Field1","RecordN Field2",--->"RecordN Field1435
 
Something like this ?
awk '{printf "%s"(NR%1435 ? "," : "\n"),$0}' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top