Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

simple awk

Posted on 2013-12-28
2
Medium Priority
?
363 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 85

Accepted Solution

by:
ozo earned 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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…
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.
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

963 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