Sponsored Content
Top Forums Shell Programming and Scripting awk Matching Columns - Am I missing something? Post 303024177 by dis0wned on Tuesday 2nd of October 2018 11:13:07 AM
Old 10-02-2018
That worked, I had to add
Code:
> $tempdir/file3 && rm $tempdir/file1.$$ $tempdir/file1

to the end of the command. One issue it created and Im not sure which part of the command is doing this but it is returning the interface that it is searching for and placing it on the line prior to the search output. Please see the output below:

Code:
Hostname,Port,Name,Status,Vlan,Duplex,Speed,Type,VLAN Name,CDP NE Hostname,CDP NE IP,CDP NE Platform,CDP NE Capabilities,Local Interface,Remote Interface,CDP NE Software,CDP NE Software,CDP NE Version,CDP NE Release,CDP NE VLAN,CDP NE Admin IP,POE Admin,POE Oper,POE Power,POE Watts,POE Device,POE Class
:Te1/1:
replaced.log,Te1/1,replaced-01,connected,trunk,full,10G,10GBase-CU 3M,NA,treplaced5),1replaced1,N5Kreplaced548P,Switch IGMP CVTA phone port,Te1/1,Fe1/1,Cisco Nexus Operating System (NX-OS) Software,Version 7.1(4)N1(1),1 1replaced,,,NA,NA,NA,NA,NA,NA,NA
:

Lastly, how were you able to determine that the sed portion of the command was not working properly? I'm trying to learn to fish. Thanks again for your help!!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk/sed search lines in file1 matching columns in file2

Hi All, as you can see I'm pretty new to this board. :D I'm struggling around with small script to search a few fields in another file. Basically I have file1 looking like this: 15:38:28 sz:10001 pr:14.16 15:38:28 sz:10002 pr:18.41 15:38:29 sz:10003 pr:19.28 15:38:30 sz:10004... (1 Reply)
Discussion started by: floripoint
1 Replies

2. Shell Programming and Scripting

using command line arguments as columns for pattern matching using awk

Hi, I wish to use a column, as inputted by a user from command line, for pattern matching. awk file: { if($1 ~ /^8/) { print $0> "temp2.csv" } } something like this, but i want '$1' to be any column as selected by the user from command line. ... (1 Reply)
Discussion started by: invinclible0009
1 Replies

3. Shell Programming and Scripting

awk - Matching columns between 2 files and reordering results

I am trying to match 4 colums (first_name,last_name,dob,ssn) between 2 files and when there is an exact match I need to write out these matches to a new file with a combination of fields from file1 and file2. I've managed to come up with a way to match these 2 files based on the columns (see below)... (7 Replies)
Discussion started by: ambroze
7 Replies

4. Shell Programming and Scripting

Find min.max value if matching columns found using AWK

Input_ File : 2 3 4 5 1 1 0 1 2 1 -1 1 2 1 3 1 3 1 4 1 6 5 6 6 6 6 6 7 6 7 6 8 5 8 6 7 Desired output : 2 3 4 5 -1 1 4 1 6 5 6 8 5 8 6 7 (3 Replies)
Discussion started by: vasanth.vadalur
3 Replies

5. Shell Programming and Scripting

Help with awk Matching columns from two files

Hello, I have two files as following: #bin chrom chromStart chromEnd name score strand observed 585 chr2 29442 29443 rs4637157 0 + C/T 585 chr2 33011 33012 rs13423995 0 + A/G 585 chr2 34502 34503 rs13386087 0 + ... (2 Replies)
Discussion started by: Homa
2 Replies

6. Shell Programming and Scripting

awk to copy previous line matching a particular columns

Hello Help, 2356798 7689867 999 000 123678 20385907 9797 666 17978975 87468976 968978 98798 I am trying to have out put which actually look for the third column value of 9797 and then it insert line there after with first, second column value exactly as the previous line and replace the third... (3 Replies)
Discussion started by: Indra2011
3 Replies

7. Shell Programming and Scripting

awk split columns after matching on rows and summing the last column

input: chr1 1 2 3 chr1 1 2 4 chr1 2 4 5 chr2 3 6 9 chr2 3 6 10 Code: awk '{a+=$4}END{for (i in a) print i,a}' input Output: chr112 7 chr236 19 chr124 5 Desired output: chr1 1 2 7 chr2 3 6 19 chr1 2 4 5 (1 Reply)
Discussion started by: jacobs.smith
1 Replies

8. Shell Programming and Scripting

awk - matching on 2 columns for differents lines

Given this file (I separated them in block to make my explanation clearer): 92157768877;Sof_deme_Fort_Email_am_%yyyy%%mm%%dd%;EMAIL;20/02/2015;1;0;0 92157768877;Sof_trav_Fort_Email_am_%yyyy%%mm%%dd%;EMAIL;20/02/2015;1;0;0 91231838895;Sof_deme_faible_Email_am;EMAIL;26/01/2015;1 0;0... (1 Reply)
Discussion started by: Andy_K
1 Replies

9. Shell Programming and Scripting

Merging multiple lines to columns with awk, while inserting commas for missing lines

Hello all, I have a large csv file where there are four types of rows I need to merge into one row per person, where there is a column for each possible code / type of row, even if that code/row isn't there for that person. In the csv, a person may be listed from one to four times... (9 Replies)
Discussion started by: RalphNY
9 Replies

10. Shell Programming and Scripting

awk merge matching columns

I know I'm not the first one asking this but my code still does not work: File 1: gi|1283| tRNAscan exon 87020 88058 . - . transcript_id "Parent=tRNA-Tyr5.r01"; gi|3283| tRNAscan exon 97020 97058 . + . transcript_id "Parent=tRNA-Tyr6.r01"; gi|4283| rRNAscan exon 197020 197058 . - . transcript_id... (5 Replies)
Discussion started by: 0sMoses
5 Replies
Info::Layer2::C1900(3pm)				User Contributed Perl Documentation				  Info::Layer2::C1900(3pm)

NAME
SNMP::Info::Layer2::C1900 - SNMP Interface to data from Cisco Catalyst 1900 Network Switches running CatOS AUTHOR
Max Baker SYNOPSIS
# Let SNMP::Info determine the correct subclass for you. my $c1900 = new SNMP::Info( AutoSpecify => 1, Debug => 1, DestHost => 'myswitch', Community => 'public', Version => 1 ) or die "Can't connect to DestHost. "; my $class = $c1900->class(); print "SNMP::Info determined this device to fall under subclass : $class "; DESCRIPTION
Provides abstraction to the configuration information obtainable from a Catalyst 1900 device through SNMP. See SNMP::Info for full documentation Note that most of these devices only talk SNMP version 1, but not all. For speed or debugging purposes you can call the subclass directly, but not after determining a more specific class using the method above. my $c1900 = new SNMP::Info::Layer2::C1900(...); Inherited classes SNMP::Info::CDP SNMP::Info::CiscoStats SNMP::Info::CiscoConfig SNMP::Info::Layer2 Required MIBs STAND-ALONE-ETHERNET-SWITCH-MIB (ESSWITCH-MIB) ESSWITCH-MIB is included in the Version 1 MIBs from Cisco. They can be found at ftp://ftp.cisco.com/pub/mibs/v1/v1.tar.gz Inherited MIBs See "Required MIBs" in SNMP::Info::CDP for its MIB requirements. See "Required MIBs" in SNMP::Info::CiscoStats for its MIB requirements. See "Required MIBs" in SNMP::Info::CiscoConfig for its MIB requirements. See "Required MIBs" in SNMP::Info::Layer2 for its MIB requirements. GLOBALS
These are methods that return scalar value from SNMP $c1900->c1900_flash_status() Usually contains the version of the software loaded in flash. Used by os_ver() "STAND-ALONE-ETHERNET-SWITCH-MIB::upgradeFlashBankStatus" $c1900->os() Returns 'catalyst' $c1900->os_ver() Returns CatOS version if obtainable. First tries to use SNMP::Info::CiscoStats->os_ver() . If that fails then it checks for the presence of $c1900->c1900_flash_status() and culls the version from there. $c1900->vendor() Returns 'cisco' :) Overrides $c1900->cisco_comm_indexing() Returns 1. Use vlan indexing. $c1900->bulkwalk_no Return 1. Bulkwalk is turned off for this class. Globals imported from SNMP::Info::CDP See "GLOBALS" in SNMP::Info::CDP for details. Globals imported from SNMP::Info::CiscoStats See "GLOBALS" in SNMP::Info::CiscoStats for details. Globals imported from SNMP::Info::CiscoConfig See "GLOBALS" in SNMP::Info::CiscoConfig for details. Globals imported from SNMP::Info::Layer2 See "GLOBALS" in SNMP::Info::Layer2 for details. TABLE METHODS
These are methods that return tables of information in the form of a reference to a hash. Overrides $c1900->interfaces() Returns reference to the map between IID and physical Port. $c1900->i_duplex() Returns reference to map of IIDs to current link duplex $c1900->i_duplex_admin() Returns reference to hash of IIDs to admin duplex setting $c1900->i_name() Crosses "ifName" with $c1900->c1900_p_name() and returns the human set port name if exists. $c1900->i_vlan() Returns a mapping between the interface and the VLAN / bridge group if overlap is not enabled. $c1900->i_vlan_membership() Returns reference to hash of arrays: key = interface, value = array of VLAN / bridge group IDs. Example: my $interfaces = $c1900->interfaces(); my $vlans = $c1900->i_vlan_membership(); foreach my $iid (sort keys %$interfaces) { my $port = $interfaces->{$iid}; my $vlan = join(',', sort(@{$vlans->{$iid}})); print "Port: $port VLAN: $vlan "; } $c1900->bp_index() Returns a bp_index that contains the original bp_index entries and extra entries for those interfaces listed in if_index, as some C1900 devices do not return complete bp_indexes. STAND-ALONE-ETHERNET-SWITCH-MIB Switch Port Table Entries: $c1900->c1900_p_index() Maps the Switch Port Table to the IID "swPortIfIndex" $c1900->c1900_p_duplex() Gives Port Duplex Info ("swPortDuplexStatus") $c1900->c1900_p_duplex_admin() Gives admin setting for Duplex Info ("swPortFullDuplex") $c1900->c1900_p_name() Gives human set name for port ("swPortName") $c1900->c1900_p_up_admin() Gives Admin status of port enabled. ("swPortAdminStatus") $c1900->c1900_p_type() Gives Type of port, i.e. "general-ethernet" ("swPortMediaCapability") $c1900->c1900_p_media() Gives the media of the port , i.e. ""fiber-sc"" ("swPortConnectorType") Table Methods imported from SNMP::Info::CDP See "TABLE METHODS" in SNMP::Info::CDP for details. Table Methods imported from SNMP::Info::CiscoStats See "TABLE METHODS" in SNMP::Info::CiscoStats for details. Table Methods imported from SNMP::Info::CiscoConfig See "TABLE METHODS" in SNMP::Info::CiscoConfig for details. Table Methods imported from SNMP::Info::Layer2 See "TABLE METHODS" in SNMP::Info::Layer2 for details. SET METHODS
These are methods that provide SNMP set functionality for overridden methods or provide a simpler interface to complex set operations. See "SETTING DATA VIA SNMP" in SNMP::Info for general information on set operations. $c1900->set_i_duplex_admin(duplex, ifIndex) Sets port duplex, must be supplied with duplex and port "ifIndex". Speed choices are 'auto', 'half', 'full'. Example: my %if_map = reverse %{$c1900->interfaces()}; $c1900->set_i_duplex_admin('auto', $if_map{'1'}) or die "Couldn't change port duplex. ",$c1900->error(1); perl v5.12.4 2011-09-28 Info::Layer2::C1900(3pm)
All times are GMT -4. The time now is 08:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy