Solved

simple awk

Posted on 2013-12-28
2
353 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
Comment Utility
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
Comment Utility
thnx
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now