Joining lines of a text file using GAWK


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Joining lines of a text file using GAWK
# 1  
Old 05-27-2010
CPU & Memory 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.

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                                                        
----------------------------------------------------------------------

I WANT THE DATA TO LOOK LIKE.....
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

HAVING THE FIELDS:
CUSTOMER NO:ADDRESS: (FIELD1, FIELD2, FIELD3)CITY:PINSmiliet Established: Dt since Cust of Bank :

pl.. help by providing script in gawk

Last edited by Scott; 05-27-2010 at 03:34 PM.. Reason: Code tags, PLEASE!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Joining lines in TXT file based on first character

Hi, I have a pipe delimeted text file where lines have been split over 2 lines and I need to join them back together. For example the file I have is similar to the following: aaa|bbb |ccc ddd|eee fff|ggg |hhh I ideally need to have it looking like the following aaa|bbb|ccc ddd|eee... (5 Replies)
Discussion started by: fuji_s
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. Shell Programming and Scripting

joining multi-line file into single lines

Hi, I have a file like mentioned below..For each specific id starting with > I want to join the sequence in multiple lines to a single line..Is there a simple way in awk or sed to do this >ENST00000558922 cdna:KNOWN TCCAGGATCCAGCCTCCCGATCACCGCGCTAGTCCTCGCCCTGCCTGGGCTTCCCCAGAG... (2 Replies)
Discussion started by: Diya123
2 Replies

4. Shell Programming and Scripting

Joining lines in a file - help!

I'm looking for a way to join lines in a file; e.,g consider the following R|This is line 1 R|This is line 2 R|This is line 3 R|This is line 4 R|This is line 5 what i want to end up with is R|This is line 1 R|This is line 2 R|This is line 3 R|This is line 4 R|This is line 5 so... (15 Replies)
Discussion started by: Storms
15 Replies

5. 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

6. Shell Programming and Scripting

bash - joining lines in a file

I’m writing a bash shell script and I want to join lines together where two variables on each line are the same ie. 12345variablestuff43212morevariablestuff 12345variablestuff43212morevariablestuff 34657variablestuff78945morevariablestuff 34657variablestuff78945morevariablestuff... (12 Replies)
Discussion started by: Cultcha
12 Replies

7. 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

8. UNIX for Dummies Questions & Answers

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... (0 Replies)
Discussion started by: KANNI786
0 Replies

9. Shell Programming and Scripting

Joining 2 lines in a file together

Hi guys, I've got a log file which has entries that look like this: ------------------------------------------------------------------------------- 06/08/04 07:57:57 AMQ9002: Channel program started. EXPLANATION: Channel program 'INSCCPQ1.HSMTSPQ1' started. ACTION: None. ... (3 Replies)
Discussion started by: m223464
3 Replies

10. Shell Programming and Scripting

Joining lines in log file

Hi, I need to develop a script to join multiple three lines in a log file into one line for processing with awk and grep. I looked at tr with no success. The first line contains the date time information. The second line contains the error line. The third line is a blank line. Thanks, Mike (3 Replies)
Discussion started by: bubba112557
3 Replies
Login or Register to Ask a Question