Solved

simple awk

Posted on 2013-12-28
2
357 Views
Last Modified: 2013-12-28
I have 2 files as given below a.txt and b.txt

i want to create a new txt file c.txt

for each lilne of text file it will read and will give result as this


Port Status Speed
1        up    1000
2        up    1000
.....



IF-MIB::ifOperStatus.1 = INTEGER: up(1)
IF-MIB::ifHighSpeed.1 = Gauge32: 1000





IF-MIB::ifOperStatus.1 = INTEGER: up(1)
IF-MIB::ifOperStatus.2 = INTEGER: up(1)
IF-MIB::ifOperStatus.3 = INTEGER: up(1)
IF-MIB::ifOperStatus.4 = INTEGER: up(1)
IF-MIB::ifOperStatus.5 = INTEGER: up(1)
IF-MIB::ifOperStatus.6 = INTEGER: up(1)
IF-MIB::ifOperStatus.7 = INTEGER: down(2)
IF-MIB::ifOperStatus.8 = INTEGER: up(1)
IF-MIB::ifOperStatus.9 = INTEGER: up(1)
IF-MIB::ifOperStatus.10 = INTEGER: up(1)
IF-MIB::ifOperStatus.11 = INTEGER: up(1)
IF-MIB::ifOperStatus.12 = INTEGER: up(1)
IF-MIB::ifOperStatus.13 = INTEGER: down(2)
IF-MIB::ifOperStatus.14 = INTEGER: down(2)
IF-MIB::ifOperStatus.15 = INTEGER: down(2)
IF-MIB::ifOperStatus.16 = INTEGER: down(2)
IF-MIB::ifOperStatus.17 = INTEGER: down(2)
IF-MIB::ifOperStatus.18 = INTEGER: down(2)
IF-MIB::ifOperStatus.19 = INTEGER: down(2)
IF-MIB::ifOperStatus.20 = INTEGER: down(2)
IF-MIB::ifOperStatus.21 = INTEGER: down(2)
IF-MIB::ifOperStatus.22 = INTEGER: down(2)
IF-MIB::ifOperStatus.23 = INTEGER: up(1)
IF-MIB::ifOperStatus.24 = INTEGER: down(2)
IF-MIB::ifOperStatus.25 = INTEGER: up(1)
IF-MIB::ifOperStatus.26 = INTEGER: down(2)
IF-MIB::ifOperStatus.27 = INTEGER: down(2)
IF-MIB::ifOperStatus.28 = INTEGER: down(2)
IF-MIB::ifOperStatus.29 = INTEGER: down(2)
IF-MIB::ifOperStatus.30 = INTEGER: down(2)
IF-MIB::ifOperStatus.31 = INTEGER: down(2)
IF-MIB::ifOperStatus.32 = INTEGER: down(2)
IF-MIB::ifOperStatus.33 = INTEGER: up(1)
IF-MIB::ifOperStatus.34 = INTEGER: up(1)
IF-MIB::ifOperStatus.35 = INTEGER: up(1)
IF-MIB::ifOperStatus.36 = INTEGER: up(1)
IF-MIB::ifOperStatus.37 = INTEGER: up(1)
IF-MIB::ifOperStatus.38 = INTEGER: down(2)
IF-MIB::ifOperStatus.39 = INTEGER: up(1)
IF-MIB::ifOperStatus.40 = INTEGER: up(1)
IF-MIB::ifOperStatus.41 = INTEGER: down(2)
IF-MIB::ifOperStatus.42 = INTEGER: up(1)
IF-MIB::ifOperStatus.43 = INTEGER: up(1)
IF-MIB::ifOperStatus.44 = INTEGER: up(1)
IF-MIB::ifOperStatus.45 = INTEGER: down(2)
IF-MIB::ifOperStatus.46 = INTEGER: down(2)
IF-MIB::ifOperStatus.47 = INTEGER: down(2)
IF-MIB::ifOperStatus.48 = INTEGER: up(1)
IF-MIB::ifOperStatus.1000 = INTEGER: notPresent(6)
IF-MIB::ifOperStatus.1001 = INTEGER: notPresent(6)
IF-MIB::ifOperStatus.1002 = INTEGER: notPresent(6)
IF-MIB::ifOperStatus.1003 = INTEGER: notPresent(6)
IF-MIB::ifOperStatus.1004 = INTEGER: notPresent(6)
IF-MIB::ifOperStatus.1005 = INTEGER: notPresent(6)
IF-MIB::ifOperStatus.1006 = INTEGER: notPresent(6)
IF-MIB::ifOperStatus.1007 = INTEGER: notPresent(6)
IF-MIB::ifOperStatus.100000 = INTEGER: up(1)

Open in new window




IF-MIB::ifHighSpeed.1 = Gauge32: 1000
IF-MIB::ifHighSpeed.2 = Gauge32: 1000
IF-MIB::ifHighSpeed.3 = Gauge32: 1000
IF-MIB::ifHighSpeed.4 = Gauge32: 1000
IF-MIB::ifHighSpeed.5 = Gauge32: 1000
IF-MIB::ifHighSpeed.6 = Gauge32: 1000
IF-MIB::ifHighSpeed.7 = Gauge32: 1000
IF-MIB::ifHighSpeed.8 = Gauge32: 1000
IF-MIB::ifHighSpeed.9 = Gauge32: 1000
IF-MIB::ifHighSpeed.10 = Gauge32: 1000
IF-MIB::ifHighSpeed.11 = Gauge32: 1000
IF-MIB::ifHighSpeed.12 = Gauge32: 1000
IF-MIB::ifHighSpeed.13 = Gauge32: 1000
IF-MIB::ifHighSpeed.14 = Gauge32: 1000
IF-MIB::ifHighSpeed.15 = Gauge32: 1000
IF-MIB::ifHighSpeed.16 = Gauge32: 1000
IF-MIB::ifHighSpeed.17 = Gauge32: 1000
IF-MIB::ifHighSpeed.18 = Gauge32: 1000
IF-MIB::ifHighSpeed.19 = Gauge32: 1000
IF-MIB::ifHighSpeed.20 = Gauge32: 1000
IF-MIB::ifHighSpeed.21 = Gauge32: 1000
IF-MIB::ifHighSpeed.22 = Gauge32: 1000
IF-MIB::ifHighSpeed.23 = Gauge32: 100
IF-MIB::ifHighSpeed.24 = Gauge32: 1000
IF-MIB::ifHighSpeed.25 = Gauge32: 100
IF-MIB::ifHighSpeed.26 = Gauge32: 1000
IF-MIB::ifHighSpeed.27 = Gauge32: 1000
IF-MIB::ifHighSpeed.28 = Gauge32: 1000
IF-MIB::ifHighSpeed.29 = Gauge32: 1000
IF-MIB::ifHighSpeed.30 = Gauge32: 1000
IF-MIB::ifHighSpeed.31 = Gauge32: 1000
IF-MIB::ifHighSpeed.32 = Gauge32: 1000
IF-MIB::ifHighSpeed.33 = Gauge32: 1000
IF-MIB::ifHighSpeed.34 = Gauge32: 1000
IF-MIB::ifHighSpeed.35 = Gauge32: 1000
IF-MIB::ifHighSpeed.36 = Gauge32: 100
IF-MIB::ifHighSpeed.37 = Gauge32: 1000
IF-MIB::ifHighSpeed.38 = Gauge32: 1000
IF-MIB::ifHighSpeed.39 = Gauge32: 1000
IF-MIB::ifHighSpeed.40 = Gauge32: 1000
IF-MIB::ifHighSpeed.41 = Gauge32: 1000
IF-MIB::ifHighSpeed.42 = Gauge32: 1000
IF-MIB::ifHighSpeed.43 = Gauge32: 1000
IF-MIB::ifHighSpeed.44 = Gauge32: 1000
IF-MIB::ifHighSpeed.45 = Gauge32: 1000
IF-MIB::ifHighSpeed.46 = Gauge32: 1000
IF-MIB::ifHighSpeed.47 = Gauge32: 1000
IF-MIB::ifHighSpeed.48 = Gauge32: 1000
IF-MIB::ifHighSpeed.1000 = Gauge32: 0
IF-MIB::ifHighSpeed.1001 = Gauge32: 0
IF-MIB::ifHighSpeed.1002 = Gauge32: 0
IF-MIB::ifHighSpeed.1003 = Gauge32: 0
IF-MIB::ifHighSpeed.1004 = Gauge32: 0
IF-MIB::ifHighSpeed.1005 = Gauge32: 0
IF-MIB::ifHighSpeed.1006 = Gauge32: 0
IF-MIB::ifHighSpeed.1007 = Gauge32: 0
IF-MIB::ifHighSpeed.100000 = Gauge32: 0

Open in new window

0
Comment
Question by:3XLcom
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 39743357
awk -F'[ .()]' '/Status/{c[$2]=$5 c[$2]}/Speed/{c[$2]=c[$2] " " $5}END{for(p in c){print p,c[p]}}' a.txt b.txt | sort -n > c.txt
0
 

Author Closing Comment

by:3XLcom
ID: 39743363
thnx
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question