Sponsored Content
Full Discussion: options with awk
Top Forums Shell Programming and Scripting options with awk Post 51103 by mips on Tuesday 11th of May 2004 06:30:04 AM
Old 05-11-2004
options with awk

Hi everybody,
I have some difficulties to use awk with the right options (as always): i have for example 3 fields:
IF-MIB::ifIndex.1
IF-MIB::ifIndex.2
IF-MIB::ifIndex.3
i want to use "while" to access to these records one by one
so i wrote this script but it didn t return the right value:

(small script which returns the 3 records) | awk 'BEGIN {FS="\n"} { i=1
while (i<4)
{ print $i
i++
}
}'

this returns me all records wheras i want only the first or the second (for example)
which corrections may i do to allow me to access to the right record
Thank you for you help
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

cp options

Hello again, Is there an option for the cp command to overwrite existing files in the destination directory? Cheers Rob (3 Replies)
Discussion started by: milage
3 Replies

2. UNIX for Dummies Questions & Answers

options

I am just beginning to learn unix and I was wondering if there was a list of all the options somewhere on the net or hidden in the man pages? Also do options always have - and then a letter, or can it be - and a number as well? Thanks! (1 Reply)
Discussion started by: terms5
1 Replies

3. AIX

no options

Hi All, I have a situation here that's very fun... I have a system with AIX and iPlanet (sunOne) installed, when occurs an unknown event on the network the WebServer shows a thousand of CLOSE_WAIT connections and this number grows and grows until the webserver crashs. I read some documents... (2 Replies)
Discussion started by: nascimento.rp
2 Replies

4. Shell Programming and Scripting

Awk and checking options

My task is that when the user calls the script 1. If user calls script with awk -v dtmax= -v stdlim= -f ../Scripts/add-rgauss-xt.awk fin.xt > fout.xt rgauss will return mean + (stdlim * sigma) 2. If user calls script with awk -v dtmax= -f ../Scripts/add-rgauss-xt.awk fin.xt > fout.xt... (4 Replies)
Discussion started by: kristinu
4 Replies

5. Shell Programming and Scripting

cut, sed, awk too slow to retrieve line - other options?

Hi, I have a script that, basically, has two input files of this type: file1 key1=value1_1_1 key2=value1_2_1 key4=value1_4_1 ... file2 key2=value2_2_1 key2=value2_2_2 key3=value2_3_1 key4=value2_4_1 ... My files are 10k lines big each (approx). The keys are strings that don't... (7 Replies)
Discussion started by: fzd
7 Replies

6. Shell Programming and Scripting

awk script file command line options

Being new to awk I have a really basic question. It just has to be in the archives but it didn't bite me when I went looking for it. I've written an awk script, placed it in a file, added the "#!/usr/bin/awk -f" at the top of the script and away I go. "% myAwk <inputfile>" gives me exactly what... (2 Replies)
Discussion started by: tomr2k
2 Replies

7. Ubuntu

Kernel boot options removed by fault, no boot options

Hello Everyone, First of all, I highly appreciate all Linux forum members and whole Linux community. http://forums.linuxmint.com/images/smilies/icon_wink.gif. I wish you the best for all of you ! I will try to be short and concise: I am using Linux Mint 10 for 2 months on 2 ws, and all went... (3 Replies)
Discussion started by: cdt
3 Replies

8. Shell Programming and Scripting

Matching options from ARGV in awk

I have written this code in an awk script. BEGIN { print "ARGV", ARGV if ( match(ARGV,/-u/) || match(ARGV,/--usg/) ) { print "MATCH -u:",match(ARGV,/-u/), RSTART, RLENGTH print "MATCH --usg:",match(ARGV,/--usg/), RSTART, RLENGTH usage() exit(1) } } I want... (7 Replies)
Discussion started by: kristinu
7 Replies
Info::Layer2::C2900(3pm)				User Contributed Perl Documentation				  Info::Layer2::C2900(3pm)

NAME
SNMP::Info::Layer2::C2900 - SNMP Interface to Cisco Catalyst 2900 Switches running IOS AUTHOR
Max Baker SYNOPSIS
# Let SNMP::Info determine the correct subclass for you. my $c2900 = new SNMP::Info( AutoSpecify => 1, Debug => 1, # These arguments are passed directly to SNMP::Session DestHost => 'myswitch', Community => 'public', Version => 2 ) or die "Can't connect to DestHost. "; my $class = $c2900->class(); print "SNMP::Info determined this device to fall under subclass : $class "; DESCRIPTION
Provides abstraction to the configuration information obtainable from a C2900 device through SNMP. For speed or debugging purposes you can call the subclass directly, but not after determining a more specific class using the method above. my $c2900 = new SNMP::Info::Layer2::C2900(...); Inherited Classes SNMP::Info::CiscoVTP SNMP::Info::CDP SNMP::Info::CiscoStats SNMP::Info::CiscoConfig SNMP::Info::Layer2 Required MIBs CISCO-C2900-MIB Part of the v2 MIBs from Cisco. Inherited MIBs See "Required MIBs" in SNMP::Info::CiscoVTP for its MIB requirements. 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 Overrides $c2900->vendor() Returns 'cisco' :) $c2900->cisco_comm_indexing() Returns 1. Use vlan indexing. Globals imported from SNMP::Info::CiscoVTP See "GLOBALS" in SNMP::Info::CiscoVTP for details. 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 $c2900->interfaces() Returns reference to the map between IID and physical Port. On the 2900 devices i_name isn't reliable, so we override to just the description. Next all dots are changed for forward slashes so that the physical port name is the same as the broad-casted CDP port name. (Ethernet0.1 -> Ethernet0/1) Also, any weird characters are removed, as I saw a few pop up. $c2900->i_duplex() Returns reference to map of IIDs to current link duplex Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex() $c2900->i_duplex_admin() Returns reference to hash of IIDs to admin duplex setting Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin() C2900-MIB Port Entry Table $c2900->c2900_p_index() Maps the Switch Port Table to the IID ("c2900PortIfIndex") $c2900->c2900_p_duplex() Gives Port Duplex Info ("c2900PortDuplexStatus") $c2900->c2900_p_duplex_admin() Gives admin setting for Duplex Info ("c2900PortDuplexState") $c2900->c2900_p_speed_admin() Gives Admin speed of port ("c2900PortAdminSpeed") Table Methods imported from SNMP::Info::CiscoVTP See "TABLE METHODS" in SNMP::Info::CiscoVTP for details. 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. $c2900->set_i_speed_admin(speed, ifIndex) Sets port speed, must be supplied with speed and port "ifIndex" Speed choices are 'auto', '10', '100' Crosses $c2900->c2900_p_index() with $c2900->c2900_p_speed_admin() to utilize port "ifIndex". Example: my %if_map = reverse %{$c2900->interfaces()}; $c2900->set_i_speed_admin('auto', $if_map{'FastEthernet0/1'}) or die "Couldn't change port speed. ",$c2900->error(1); $c2900->set_i_duplex_admin(duplex, ifIndex) Sets port duplex, must be supplied with duplex and port "ifIndex" Speed choices are 'auto', 'half', 'full' Crosses $c2900->c2900_p_index() with $c2900->c2900_p_duplex_admin() to utilize port "ifIndex". Example: my %if_map = reverse %{$c2900->interfaces()}; $c2900->set_i_duplex_admin('auto', $if_map{'FastEthernet0/1'}) or die "Couldn't change port duplex. ",$c2900->error(1); perl v5.12.4 2011-09-28 Info::Layer2::C2900(3pm)
All times are GMT -4. The time now is 06:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy