JOINING MULTIPLE LINES IN A TEXT FILE USING GAWK


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers JOINING MULTIPLE LINES IN A TEXT FILE USING GAWK
# 1  
Old 05-27-2010
JOINING MULTIPLE LINES IN A TEXT FILE USING GAWK

sir... am having a data file of customer master., containing some important fields as a set one line after another.,

what i want is to have one set of these fields(rows) one after another in line.........then the second set... and so on... till the last set completed.





I WANT THE DATA TO LOOK LIKE.....


Code:
Customer No :   10000  RAMAKRISHNA REDDY 
Address     :      FLAT NO101     
                       RK  MANSIONS                                 
                       PARK ROAD COLONY
City        :BLG                  PIN : 560009                                                                                              
Dt Established :  01/01/2000    Dt since Cust of Bank :    01/01/2001      
Individual/Others :  INDIVIDUAL             Constitution Cd : ******* Profession Cd :  NOT AVAILABLE           
FREEZE Type : TOTAL FREEZE             FREEZE Reason : OTHERS                                                        
----------------------------------------------------------------------
Customer No :   10001  RAMAKRISHNA RAO 
Address     :      FLAT NO333      
                       SLN MANSIONS                                 
                      PARK ROAD COLONY
City        :BANGALORE                 PIN : 560009                                                                                              
Dt Established :  01/01/2001    Dt since Cust of Bank :    01/01/2003      
Individual/Others :  INDIVIDUAL     Constitution Cd : ******* Profession Cd :  NOT AVAILABLE           
FREEZE Type : TOTAL FREEZE             FREEZE Reason : OTHERS                                                        
----------------------------------------------------------------------


HAVING THE FIELDS:
CUSTOMER NO:ADDRESS: (FIELD1, FIELD2, FIELD3)CITY:PINSmiliet Established: Dt since Cust of Bank :
THE DATA IS TO APPEAR AS :
Code:
10000 RAMAKRISHNA REDDY FLAT NO333  SLN MANSIONS PARK ROAD COLONY BANGALORE  560009   01/01/2000  01/01/2001 
10000 RAMAKRISHNA REDDY FLAT NO333  SLN MANSIONS PARK ROAD COLONY BANGALORE  560009   01/01/2000  01/01/2001

pl.. help by providing script in gawk
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk joining multiple lines based on field count

Hi Folks, I have a file with fields as follows which has last field in multiple lines. I would like to combine a line which has three fields with single field line for as shown in expected output. Please help. INPUT hname01 windows appnamec1eda_p1, ... (5 Replies)
Discussion started by: shunya
5 Replies

2. UNIX for Advanced & Expert Users

Text formatting - joining lines

I have large file with data as below, in unix using sed or some cammand how to get output as below. cat 1.txt Normal data 1|AA|NN 4|BB|NNN C|DDD|N //Additional details 9C|12C|8N Specific Details 12N|JIN|KK\NY1\ 345\ABC1\KKK 90|ENO0|NDO 17|NO921|NCOKL output shoud be as below ... (10 Replies)
Discussion started by: Tecnical_help12
10 Replies

3. UNIX for Dummies Questions & Answers

How to grep multiple lines from a text file using another text file?

I would like to use grep to select multiple lines from a text file using a single-column text file. Basically I want to only select lines from the first text file where the second column of the first text file matches the second text file. How do I go about doing that? Thanks! (5 Replies)
Discussion started by: evelibertine
5 Replies

4. Windows & DOS: Issues & Discussions

Gawk on Windows: Joining lines only if 1st field matches

Hi.. i have two files:: file_1:: mOnkey huMAnfile_2:: Human:hates:banana i:like:*** Monkey:loves:banana dogs:kill:catsdesired output:: Monkey:loves:banana Human:hates:bananaso only when the 1st field matches from both files print it from file_2 ((case-sensitive)) i also would like... (21 Replies)
Discussion started by: M@LIK
21 Replies

5. Shell Programming and Scripting

Joining lines in a text file using AWK or SED

Hi All I'm struggling a bit here :( I need a way of joining lines contained in a text file. I've seen numerous SED and AWK examples and none of them seem to be working for me. The text file has 4 lines: DELL1427 DOC 30189342 79 Now bear with me on this one as I'm actually... (4 Replies)
Discussion started by: huskie69
4 Replies

6. UNIX for Dummies Questions & Answers

How to generate multiple lines in a text file?

Hello, I want to create a file whose content is multiple lines of strings. The string has the following pattern: aaaa/bbbb/A-B.txt A is a variable ranges from A1 to A2 B is a variable ranges from B1 to B2 Any ideas? Thanks. (17 Replies)
Discussion started by: vic005
17 Replies

7. Shell Programming and Scripting

Joining contents in multiple lines to a single line

I do have a file with contents splited into multiple lines ADSLHLJASHGLJSKAGHJJGAJSLGAHLSGHSAKBV AJHALHALHGLAGLHGBJVFBJVLFDHADAH GFJAGJAGAJFGAKGAKGFAK AJHFAGAKAGAGKAKAKGKAGFGJDGDJJDGJDJDFAG ... ... .... 100's of lines I would like to rearrange the content of this file so it will be a... (1 Reply)
Discussion started by: Lucky Ali
1 Replies

8. UNIX for Dummies Questions & Answers

Joining lines of a text file using GAWK

sir... am having a data file of customer master., containing some important fields as a set one line after another., what i want is to have one set of these fields(rows) one after another in line.........then the second set... and so on... till the last set completed. ... (0 Replies)
Discussion started by: KANNI786
0 Replies

9. Shell Programming and Scripting

[bash help]Adding multiple lines of text into a specific spot into a text file

I am attempting to insert multiple lines of text into a specific place in a text file based on the lines above or below it. For example, Here is a portion of a zone file. IN NS ns1.domain.tld. IN NS ns2.domain.tld. IN ... (2 Replies)
Discussion started by: cdn_humbucker
2 Replies

10. Shell Programming and Scripting

Joining multiple lines

I have data of the following form. It starts its first line with a '{' and ends the last line with a '}'. What I need to do is to join every line starting with the '{' and ending with the '} into one line in the output file. If it was just this one block, I could do a 13 joins in vi, however it... (4 Replies)
Discussion started by: beilstwh
4 Replies
Login or Register to Ask a Question