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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help needed - ksh shell scripting subbu Shell Programming and Scripting 5 02-15-2008 12:53 PM
Help needed - shell scripting garric Shell Programming and Scripting 8 05-23-2006 07:08 AM
difference between AIX shell scripting and Unix shell scripting. haroonec Shell Programming and Scripting 2 04-12-2006 09:12 AM
help needed in shell scripting......urgent swamymns Shell Programming and Scripting 3 12-06-2005 11:10 PM

Closed Thread
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
  #1 (permalink)  
Old 07-14-2006
cskumar cskumar is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 67
SHell Scripting Help Needed

Dear All,

I have an input file like this
interface Serial10/0/7:11.1 point-to-point
description CLIENT:SA_INSTITUTO ANGLO MEXICANO Sitio Metepec 104452:0,165
bandwidth 64
ip vrf forwarding INSTITUTO-ANGLO

ip address 192.168.148.217 255.255.255.252
no ip directed-broadcast
frame-relay interface-dlci 108
class Link_30-50-0-128
!


I can give the fields like this
interface Serial
description CLIENT:
ip address
class

And I want the repective values as,
10/0/7:11.1|SA_INSTITUTO ANGLO MEXICANO Sitio Metepec |192.168.148.217 |Link_30-50-0-128

Can anyone help me?
  #2 (permalink)  
Old 07-14-2006
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
Try something like...
Code:
$ cat file1
interface Serial
description CLIENT:
ip address
class

$ cat file2
interface Serial10/0/7:11.1 point-to-point
description CLIENT:SA_INSTITUTO ANGLO MEXICANO Sitio Metepec 104452:0,165
bandwidth 64
ip vrf forwarding INSTITUTO-ANGLO

ip address 192.168.148.217 255.255.255.252
no ip directed-broadcast
frame-relay interface-dlci 108
class Link_30-50-0-128
!

$ awk 'NR==FNR{a[$0];next}{for(i in a)if(sub(i,"")){if(NF>1)$NF="";print}}' file1 file2|paste -s -d '|' > file3

$ cat file3
10/0/7:11.1 |SA_INSTITUTO ANGLO MEXICANO Sitio Metepec |192.168.148.217 | Link_30-50-0-128

  #3 (permalink)  
Old 07-17-2006
cskumar cskumar is offline
Registered User
  
 

Join Date: Oct 2005
Posts: 67
Thanks a lot

Hi,

Thanx a lot,As Iam new with awk,can u explain me the scripts.
And one more question,If we got a number of records,how can we segregate it by another line.

For Eg:
interface Serial10/0/2:1
description CLIENT:SEIEM_TOLUCA_CORP_1024K 101983:0,542
no ip address
no ip directed-broadcast
encapsulation frame-relay
no fair-queue
!
interface Serial10/0/2:1.1 point-to-point
description CLIENT:SEIEM_TOLUCA_CORP_1024K 101983:0,542
ip vrf forwarding SEIEM
ip address 192.168.158.77 255.255.255.252
no ip directed-broadcast
frame-relay interface-dlci 436
class Link_20-60-0-1024
!

10/0/2:1|SEIEM_TOLUCA_CORP_1024K|||
10/0/2:1.1|SEIEM_TOLUCA_CORP_1024K|192.168.158.77|Link_20-60-0-1024|
Closed Thread

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 09:12 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