LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-30-2008, 08:16 AM   #1
0.o
Member
 
Registered: May 2004
Location: Raleigh, NC
Distribution: Debian, Solaris, HP-UX, AIX
Posts: 208

Rep: Reputation: 35
Help splitting individual mibs


Howdy,

I have a master list of mibs in a text file. This text file contains all mibs that are being used on a NMS. It is in the following format:

DMTF-DMI-MIB DEFINITIONS ::= BEGIN


...
...


END
Anothermib ::= BEGIN


...
...


...
END

Where the DMTF-DMI-MIB is the name of the mib and the BEGIN signifies the start of the mib and likewise, end signifies the end of the mib. I would like to split this back out into their own files. How can i select only the lines between BEGIN and END while also spitting it out into the correct file name?
 
Old 09-30-2008, 06:44 PM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Use GAWK:
Code:
#!/bin/gawk
/:=[[:space:]]*BEGIN/{
  $0 ~ /[[:space:]]*:=/;
  out = $1;
  print > out;
  while (getline) {
    print > out;
    if ($1 == "END") break;
  }
}
Invoked thusly: gawk -f split.awk mib.txt

Last edited by PTrenholme; 09-30-2008 at 06:46 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Installing MIBS Faiza Linux - Networking 1 12-11-2006 11:27 PM
Compiling mibs Mithrilhall Linux - Software 0 11-03-2006 07:17 AM
adding new MIBS JJX Linux - Software 0 10-11-2005 04:52 AM
how are mibs updated anubhuti_k Linux - Networking 0 02-16-2005 10:42 AM
SNMP: compiling MIBS WiWa Linux - Networking 0 08-25-2003 07:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration