need help appending lines/combining lines within a file...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need help appending lines/combining lines within a file...
# 1  
Old 01-06-2006
need help appending lines/combining lines within a file...

Is there a way to combine two lines onto a single line...append the following line onto the previous line?

I have the following file that contains some blank lines and some lines I would like to append to the previous line...

current file:
checking dsk c19t2d6

checking dsk c19t2d7

checking dsk c19t3d0

checking dsk c21t0d4
/dev/dsk/c21t0d4

checking dsk c21t0d5
/dev/dsk/c21t0d5

checking dsk c21t0d6
/dev/dsk/c21t0d6

checking dsk c21t0d7
/dev/dsk/c21t0d7


looking for something like this:

checking dsk c19t2d6
checking dsk c19t2d7
checking dsk c19t3d0
checking dsk c21t0d4 /dev/dsk/c21t0d4
checking dsk c21t0d5/dev/dsk/c21t0d5
checking dsk c21t0d6/dev/dsk/c21t0d6
checking dsk c21t0d7/dev/dsk/c21t0d7

any assistance would be appreciated...thanks and happy new year,
manny
# 2  
Old 01-06-2006
Code:
nawk -v RS='' '{gsub("\n", OFS)}1' myFile


Last edited by vgersh99; 01-06-2006 at 06:39 PM..
# 3  
Old 01-06-2006
checking c12t15d0 /dev/dsk/c12t15d0
checking c12t15d1 /dev/dsk/c12t15d1
checking c12t15d2 /dev/dsk/c12t15d2
checking c12t15d3 /dev/dsk/c12t15d3
checking c12t15d4 /dev/dsk/c12t15d4
checking c12t15d5 /dev/dsk/c12t15d5
checking c12t15d6
checking c12t15d7
checking c13t0d0
checking c13t0d1
checking c13t0d2
checking c13t0d3
checking c13t0d4
checking c13t0d5
checking c13t0d6
checking c13t0d7
checking c13t1d0
checking c13t1d1
checking c13t1d2
checking c13t1d3
checking c13t1d4
checking c13t1d5
checking c13t1d6
checking c13t1d7


worked like a charm...thank you Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending lines in a file

Hello, I have a file like: str1,"HEX"H,(39),info str2,"HEX"H,(854548),info str3,"HEX"H,'BGTOUR',info str4,"HEX"H,(534322),info str1,"HEX"H,,info str3,"HEX"H,'Landing',info str4,"HEX"H,'BG',info str1,"HEX"H,,info str3,"HEX"H,'Ay',info str1,"HEX"H,(27),info str2,"HEX"H,(854548),info... (2 Replies)
Discussion started by: apenkov
2 Replies

2. Shell Programming and Scripting

Need help on appending all the lines in a file after a pattern is found

Hi Friends, I am working on a file which has content as follows Wed,Database,ABC_cube,loaded Wed,Logging,out,user,302002654,active,for,0,minutes Wed,Logging,out,user,109000151,active,for,8,minutes Wed,Logging,out,user,302002654,active,for,0,minutes... (8 Replies)
Discussion started by: dev.devil.1983
8 Replies

3. UNIX for Dummies Questions & Answers

Grouping or appending the lines in a file through Unix

Hi, I am looking for a way to Group the Lines in a file.. Basically My file structure is something like this A 1 100 abc def A 1 200 abc def A 1 300 abc def A 2 100 pqr def A 2 200 pqr def A 2 300 pqr def A 1 100 abc def A 1 200 xyz def A 1 300 xyz def I need it as... (6 Replies)
Discussion started by: mkandula1983
6 Replies

4. Shell Programming and Scripting

Grouping or appending the lines in a file through Unix

Hi, I am looking for a way to Group the Lines in a file.. Basically My file structure is something like this A 1 100 abc def A 1 200 abc def A 1 300 abc def A 2 100 pqr def A 2 200 pqr def A 2 300 pqr def A 1 100 abc def A 1 200 xyz def A 1 300 xyz def I need it as... (1 Reply)
Discussion started by: mkandula1983
1 Replies

5. Shell Programming and Scripting

Reading two lines in a while loop and combining the lines

Dear all, I have a file like this: imput scaffold_0 1 scaffold_0 10000 scaffold_0 20000 scaffold_0 25000 scaffold_1 1 scaffold_1 10000 scaffold_1 20000 scaffold_1 23283 and I want the output like this: scaffold_0 1 scaffold_0 10000 scaffold_0 10000 scaffold_0 20000... (6 Replies)
Discussion started by: valente
6 Replies

6. Shell Programming and Scripting

Combining 2 lines in a file into 1 line

Hi all, I have a file with lot of lines with repeating pattern. ( TABLE_NAME line followed by Total line). I would like combine these two lines into one line seperated by cama and create a new file. Is there a simple way to do this. Current Format ( just a sample 4 lines ) TABLE_NAME:... (10 Replies)
Discussion started by: MKNENI
10 Replies

7. Shell Programming and Scripting

Combining lines between two specific lines

Hi, I have a requirement like following: I have input file like: Question: 1 ----Multiple choice--- What is your favourite colour? Options: a) red b) blue c) none of these Question: 2 ---Multiple choice----- In which month did you join your first job? Options: a) Jan b) Feb c)... (11 Replies)
Discussion started by: ppatra
11 Replies

8. Shell Programming and Scripting

appending lines to a file dynamically

Hi all, I have a file with some number of lines. I need to add certain number of lines from another file which may vary according to the user's input and to it. eg code: I/P file 1 apps/file/xyz apps/file/abc apps/file/def file 2 progs/file/xyz ... (2 Replies)
Discussion started by: Ananthdoss
2 Replies

9. UNIX for Dummies Questions & Answers

Combining lines of files to new file

Hi everybody. I have a number of files that i would like to combine. however not concatenating, but rather extract lines from the files. Example: File1 ------ File2 ------File3 ... line11 ---- line21 ---- line31 ... line12 ---- line22 ---- line32 ... line13 ... (3 Replies)
Discussion started by: kabbo
3 Replies

10. Shell Programming and Scripting

searching thru or combining multiple lines in a unix file

This is the problem actually: This regex: egrep "low debug.*\".*\"" $dbDir/alarmNotification.log is looking for data between the two quotation marks: ".*\" When I hate data like this: low debug 2009/3/9 8:30:20.47 ICSNotificationAlarm Prodics01ics0003 IC... (0 Replies)
Discussion started by: ndedhia1
0 Replies
Login or Register to Ask a Question