The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 05:44 PM
Script to add a single line to middle of text file. progkcp Shell Programming and Scripting 2 05-12-2008 03:44 PM
difference between double inverted coma and single inverted comma abhisekh_ban Shell Programming and Scripting 1 02-15-2007 11:03 AM
Second comma to new line. deepakwins UNIX for Dummies Questions & Answers 3 02-14-2007 02:35 AM
Add a comma at end of every line ST2000 Shell Programming and Scripting 4 07-14-2002 07:49 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-07-2008
ntgobinath ntgobinath is offline
Registered User
  
 

Join Date: May 2008
Posts: 38
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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:53 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0