The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to convert a single column into several rows and columns? ashton_smith UNIX for Dummies Questions & Answers 5 05-24-2008 01:44 PM
Script to add a single line to middle of text file. progkcp Shell Programming and Scripting 2 05-12-2008 11:44 AM
difference between double inverted coma and single inverted comma abhisekh_ban Shell Programming and Scripting 1 02-15-2007 08:03 AM
Second comma to new line. deepakwins UNIX for Dummies Questions & Answers 3 02-13-2007 11:35 PM
Add a comma at end of every line ST2000 Shell Programming and Scripting 4 07-14-2002 03:49 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-07-2008
Registered User
 

Join Date: May 2008
Posts: 27
Question Script needs to be modified - Each 5 Rows to be joined in single line with comma (,)

Hi All,

I'm using the following script to produce a result:

#!/bin/sh
awk ' $0 ~ /\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+Interface\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+\+/ {
match_str="YES"; line_cnt=0; next; }
{
if((line_cnt < 5) && ( match_str=="YES"))
{
print $0;
line_cnt += 1;
}
else {
match_str="NO"; line_cnt=0; }
}' InputFileName

I'm getting the following result:

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 convert Each 5 Rows to 5 Columns separated with , (comma).

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

I have modify the above script according to my requirement. Pls. anybody help me out.

Thanks,
Gobinathan.S
Reply With Quote
Google The UNIX and Linux Forums
Forum Sponsor
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0