Join Every 5 Lines With $ Symbol


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Join Every 5 Lines With $ Symbol
# 1  
Old 05-08-2008
Question Join Every 5 Lines With $ Symbol

Hi All,

I have output like this in one file.

IFName: aust00m1.mis.amat.com[ 0 [ 257 ] ]
ObjID: 5eceea48-0d59-71dd-1512-9887a1f10000
IFAlias: Dest: AMNA austkchr1-ser0/0/0:0.315 Type: FRASI CID: DHEC.559128
IFDescription: ATM9/1/0.315-atm subif
Status: Normal
IFName: aust00m1.mis.amat.com[ 0 [ 258 ] ]
ObjID: 5ed18d98-0d59-71dd-1512-9887a1f10000
IFAlias: Dest: AMNA austkchr1-ser0/0/0:0.315 Type: FRASI CID: DHEC.559128
IFDescription: ATM9/1/0.315-aal5 layer
Status: Normal
IFName: aust00m1.mis.amat.com[ 0 [ 259 ] ]
ObjID: 5ed53358-0d59-71dd-1512-9887a1f10000
IFAlias: Dest: AMNA austkchr1-ser0/0/1:0.325 Type: FRASI CID: DHEC.531638
IFDescription: ATM9/1/0.325-atm subif
Status: Normal


I want to Join every 5 lines with $ symbol.

Output should be:

IFName: aust00m1.mis.amat.com[ 0 [ 257 ] ]$ObjID: 5eceea48-0d59-71dd-1512-9887a1f10000$IFAlias: Dest: AMNA austkchr1-ser0/0/0:0.315 Type: FRASI CID: DHEC.559128$IFDescription: ATM9/1/0.315-atm subif$Status: Normal

Pls. anybody give me script for this requirement.

Thanks,
Gobinathan.s
# 2  
Old 05-08-2008
Code:
awk ' $0 ~ /^Status/ { line =line "$" $0; print line; line= ""; next}
        { if(line == "") {line = $0 } else { line = line "$" $0;}}' <Filename>

# 3  
Old 05-08-2008
Use nawk or /usr/xpg4/bin/awk on Solaris:

Code:
awk 'ORS=NR%5?"$":RS' input

# 4  
Old 05-08-2008
Thank you all.

Rado, your script worked well to resolved my requirement.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to add lines with symbol to output file

In the awk below which does execute I get output that is close, except for all the lines that start with a # are removed. Some lines have one others two or three and after the script adds the ID= to the fields below the pattern in the awk, I can not seem to add the # lines back to the output. ... (5 Replies)
Discussion started by: cmccabe
5 Replies

2. Shell Programming and Scripting

Join Lines

Hi how do I join files like below in script. Thanks, Ashan there are may line like this in the file. zone name DR_TMP_A_sev1_3eA vsan 200 pwwn 50:00:09:73:f0:16:35:08 pwwn c0:50:76:08:6e:dc:00:16 zone name DR_TMP_A_SVR2_3eA vsan 200 pwwn 50:00:09:73:f0:16:35:08 pwwn... (4 Replies)
Discussion started by: ashanabey
4 Replies

3. Shell Programming and Scripting

join two lines

I want to join this two lines but only when after him I have nothing or a comma Yes, I know Jonesy, and I'll give him about one more minute. this two lines must become Yes, I know Jonesy, and I'll give him about one more minute. thank you very much (11 Replies)
Discussion started by: thailand
11 Replies

4. Shell Programming and Scripting

join 2 lines

hi all i have sample and i need script to do this /dev/xxx oracle test /dev/sap 9999 000 88 99 i need the out put like this /dev/xxx oracle test /dev/sap 9999 000 88 99 can any one provide me with an idea to solve this problem (8 Replies)
Discussion started by: maxim42
8 Replies

5. Shell Programming and Scripting

Join the lines

Hi All, Currently, the output looks like this: hdisk0 queue_depth:3 hdisk1 queue_depth:3 hdisk2 queue_depth:1 hdisk3 queue_depth:1 I need to change the format to look like this: hdisk0 queue_depth:3 hdisk1 queue_depth:3 hdisk2 queue_depth:1 (8 Replies)
Discussion started by: Beginer0705
8 Replies

6. Shell Programming and Scripting

join lines

input1 x x input2 y x x z join input1 input2>>output ouput x x (2 Replies)
Discussion started by: repinementer
2 Replies

7. Shell Programming and Scripting

merge lines into single line based on symbol \t

The symbols are \t and \t\t (note: not tab) If the line starts with \t merge them into a single line upto symbol \t\t \t\t to end and start new line I able to join in a single line but not ending at \t\t and I completely confused help would be appreciated:b::D Input \ta tab XXXXXXXXXX \te... (5 Replies)
Discussion started by: repinementer
5 Replies

8. Shell Programming and Scripting

[AWK] read lines with \x00 symbol

I want to read a large (~1-4Gb) txt file with fields separated by "," and line separator "\n". Unfortunately, file contains \x00 (zero ASCII) symbols AWK treats them as end of line + it ignores reminder of the line after the \x00. As a simple example: echo "\0060\0061\000\0060\0063" | nawk... (6 Replies)
Discussion started by: Murfury
6 Replies

9. UNIX for Dummies Questions & Answers

how to join lines

can anyone tell me as "how to join all lines in a file " using a shell script Actually i have many files in a directory and for each file i want to join all the lines using a shell scrip . Thanks in advance!!! (8 Replies)
Discussion started by: glamo_2312
8 Replies

10. Shell Programming and Scripting

join two lines together

Hi, I have a file with on one line a uid, and on the next line a date. I am trying to make the to into one line. Here's an example: koppx 20031125 kraan 20031119 sarox 20031107 And this is what i want it to be: koppx;20031125 kraan;20031119 sarox;20031107 I have been trying... (4 Replies)
Discussion started by: tine
4 Replies
Login or Register to Ask a Question