Sponsored Content
Top Forums Shell Programming and Scripting awk? extract quoted "" strings from multiple lines. Post 302660963 by genzo on Sunday 24th of June 2012 04:46:15 AM
Old 06-24-2012
Thanks a lot! It worked for my example above.Smilie
However, It failed when I tried to use this for whole IF-MIB content.(attached)

-----
Code:
[user@host MIB]$ awk '
  /NOTIFICATION-TYPE/{
    if(s)print s
    s=sprintf("%10-s",$1)
  }
  f>0{
    $1=$1
    s=s OFS $0
  }
  /"/{
    f--
  }
  /DESCRIPTION/{
    f=2
  }
  END{
    if(s)print s
  }
' ./IF-MIB.mib
 continue to exist after the next restart."ther they willlid: for network
 of ifOperStatus."r state is indicated by the included valuercting in
 END { ifCompliances 2 }quired."nor is support for the value0ing in an
[user@host MIB]

-----

My goal is to extract the description field of "NOTIFICATION-TYPE" events only, though there is some odd strings in the mib file.... UmmmSmilie

Last edited by Scrutinizer; 06-24-2012 at 06:45 AM.. Reason: code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

Extract Part of a "Word", using AWK or SED????

I have been lurking on this forum for some time now and appreciate Everyone's help. I need to find a way to get the SystemID from this XML file. The file is much larger than just this one line but I can grep and get this line Printed. But really just need the "systemid". <test123: prefintem... (9 Replies)
Discussion started by: elbombillo
9 Replies

3. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

4. Shell Programming and Scripting

Extract text between two specified "constant" texts using awk

Hi All, From the title you may know that this question has been asked several times and I have done lot of Googling on this. I have a Wikipedia dump file in XML format. All the contents are in one XML file i.e. all different topics have been put in one XML file. Now I need to separate them and... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

7. Shell Programming and Scripting

AWK for multiple line records RS="^" FS="#"

I have to pull multiple line records with ^ as the record separator(RS)... # should be my field separator (FS)... Sample record is: ^-60#ORA-00060: deadlock detected while waiting for resource ORA-00001: unique constraint (SARADM.TCKNUM_PK) violated#PROC:AVAILABLE_FOR_GETNXTTIC#02/27/2012... (7 Replies)
Discussion started by: Vidhyaprakash
7 Replies

8. Shell Programming and Scripting

finding the strings beween 2 characters "/" & "/" in .txt file

Hi all. I have a .txt file that I need to sort it My file is like: 1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO) 2- ... (10 Replies)
Discussion started by: Behrouzx77
10 Replies

9. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

10. UNIX for Beginners Questions & Answers

Extract delta records using with "comm" and "sort" commands combination

Hi All, I have 2 pipe delimited files viz., file_old and file_new. I'm trying to compare these 2 files, and extract all the different rows between them into a new_file. comm -3 < sort file_old < sort file_new > new_file I am getting the below error: -ksh: sort: cannot open But if I do... (7 Replies)
Discussion started by: njny
7 Replies
snmp_variables(4)						   File Formats 						 snmp_variables(4)

NAME
snmp_variables - format of specifying variable names to SNMP tools SYNOPSIS
system.sysdescr.0 DESCRIPTION
Variable names for SNMP are in the format of Object Identifiers (ASN.1). There are several methods of representation. Each variable name is given in the format of A.B.C.D...., where A, B, C, and D are subidentifiers in one of two forms of notation. Each subidentifier can be encoded as a decimal integer or a symbol as found in the RFC 1066 MIB. The case of the symbols is not significant. If there is no leading period (.) in the variable name, the name will be formed as if having been preceded with iso.org.dod.internet.mgmt.mib. . A period must be placed before the first variable if the user is to fully specify the name. For example: 1.1.0 system.sysDescr.0 1.sysDescr.0 ...all refer to the same variable name. Likewise: .1.3.6.1.2.1.1.1.0 .iso.org.dod.internet.mgmt.mib.system.sysdescr.0 .1.3.6.1.2.1.1.sysdescr.0 ...all refer to the same variable name. The description of the variables in the MIB is given in the set of MIB files defined by the MIBS environment variable (or the default list defined at compilation time) and the MIB files in the /etc/sma/snmp/mibs directory (or the MIBDIRS environment variable). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |External | +-----------------------------+-----------------------------+ SEE ALSO
snmpd.conf(4), attributes(5), sma_snmp(5) RFC 1065, RFC 1066, RFC 1067, ISO IS 8824 (ASN.1) SunOS 5.10 16 Jan 2004 snmp_variables(4)
All times are GMT -4. The time now is 03:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy