Solved

simple awk

Posted on 2013-12-28
2
361 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

628 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