Sponsored Content
Full Discussion: formatting text
Top Forums Shell Programming and Scripting formatting text Post 302100943 by esham on Tuesday 26th of December 2006 05:54:34 AM
Old 12-26-2006
formatting text

Hi,

I am having a file containing entries like:

.iso.org.dod.internet.mgmt.mib-2.system.sysName.0
.iso.org.dod.internet.mgmt.mib-2.system.sysLocation.0
.iso.org.dod.internet.mgmt.mib-2.system.sysServices.0
.iso.org.dod.internet.mgmt.mib-2.system.sysORLastChange.0
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifNumber.0
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifIndex.1
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifIndex.2
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifIndex.3
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifDescr.2
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifDescr.3
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifDescr.4
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifType.1
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifType.2
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifType.3



Here what the output must be like

.iso.org.dod.internet.mgmt.mib-2.system.sysName.0
.iso.org.dod.internet.mgmt.mib-2.system.sysLocation.0
.iso.org.dod.internet.mgmt.mib-2.system.sysServices.0
.iso.org.dod.internet.mgmt.mib-2.system.sysORLastChange.0
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifNumber.0
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifIndex.1
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifDescr.2
.iso.org.dod.internet.mgmt.mib-2.interfaces.ifTable.ifEntry.ifType.1

That means, if the last field of each line is defferent of that of the previous line, the dont print that line, otherwise print.

Please help me in doing this.

Thanks in advance
esham
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Text Formatting

I have a file like this with 1 lac lines. 1 2 3 4 5 6 7 8 9 0 I would like to format the above text file 1 2 3 4 5 6 7 8 9 0 (7 Replies)
Discussion started by: aravindj80
7 Replies

2. UNIX for Dummies Questions & Answers

Text file formatting

Hi all! I'm new in unix, and faced with some difficulties. So I have text file f.e. "textfile" which contains rows like: aaa bbb ccc ddd How could I format it, so the file looks like: aaabbb cccddd Thanks in andvance (5 Replies)
Discussion started by: consta.v
5 Replies

3. Shell Programming and Scripting

text formatting

Hi, any idea input: mr.smith stvenson: /address #/tel no/ personal data profile. mrs.smith stevenson: /address #/tel no/occupation/ personal data profile. output: mr.smith stvenson address #: tel no: personal data profile. mrs.smith stevenson address #: tel no: occupation:... (7 Replies)
Discussion started by: kenshinhimura
7 Replies

4. UNIX for Dummies Questions & Answers

Formatting TEXT

Hello, I have the following lines in a text file: /var/spool/postfix/defer/1/15C86B0547C /var/spool/postfix/defer/1/19AD1B054A2 /var/spool/postfix/defer/2/25A16B05493 /var/spool/postfix/defer/6/626FBB05496 /var/spool/postfix/defer/6/634D4B0544A /var/spool/postfix/defer/6/6A8ACB05499... (2 Replies)
Discussion started by: mojoman
2 Replies

5. Shell Programming and Scripting

Text formatting

I have an input file as below. 1 Sanjib Gayen 2 Chetan Jadhav 3 Vijaykumar Uddi 4 Pinaki Sarkar I want to generate an output file as below. 1-Sanjib Gayen 2-Chetan Jadhav (4 Replies)
Discussion started by: R0H0N
4 Replies

6. Shell Programming and Scripting

Text formatting

A folder is having n number of files each file is having column names in it .Hence using below code . for file in /xxx/sss/* do filename=$( basename $file ) sed -e '1,2d; $d; /^*$/d; /selected\.$/d' ${file} | \ sed -e '1s/^/INSERT INTO '${filename}' VALUES (/; $!s/$/,/; $s/$/);/'... (6 Replies)
Discussion started by: rocking77
6 Replies

7. Shell Programming and Scripting

Help with Text formatting

I am generating the o/p as: BLANSWER 112747 112747 TBLQSTN 983 692 INITIATIVE 35 35 PAIGN 3122 3538 IGNCONTACT 90136 93534 IGNGROUP 27 27 AIGNSTEP 16899 20437 AIGNTYPE ... (1 Reply)
Discussion started by: karumudi7
1 Replies

8. Shell Programming and Scripting

Text formatting help

I have bunch of files with data's like below. archive.log.0104 ar0104_akl ar0731_rln ar0731_rsl M70148I need to compile all those files into a single file(.xls file) in the below format. 1st row is file name - should come in 1st column in excel In 2 - 4 row, all entries starts with... (13 Replies)
Discussion started by: vasanth_123
13 Replies

9. Shell Programming and Scripting

Help Me with the formatting of text

Hi, I am new to this forum; I need a help for my scripting problem. I have made a script in Unix which is extracting a report but the issue is that report is not in a proper format. Original Report Ex: Field 1....................... a b c d e f g Field 2............. @ID.@ID Field... (4 Replies)
Discussion started by: tush
4 Replies

10. Post Here to Contact Site Administrators and Moderators

Text formatting

I know I've been away from the forums for past couple of months. But I am back now : ) I used to hit ctrl+B and ctrl+I after selecting the text to make text bold or italic respectively. (Pressing the keys would add and tags etc) However, that is not working anymore. Did I miss something? (13 Replies)
Discussion started by: clx
13 Replies
snmptranslate(1m)														 snmptranslate(1m)

NAME
snmptranslate - translate SNMP OID values into a more useful form SYNOPSIS
/usr/sfw/bin/snmptranslate [-D token...] [-h] [-m miblist] [-M dirlist] [-T transopts] [common options] OID [OID...] snmptranslate is an application that translates one or more SNMP object identifier values from their symbolic (text) forms into their numerical forms or vice-versa. OID is either a numeric or text object identifier. The following options are supported: -D token[,...] Turn on debugging output for the specified token(s). Use ALL for extremely verbose output. -h Display a brief usage message and then exit. -m miblist Specifies a colon-separated list of MIB modules to load for this application. This overrides the environment variable MIBS. The special keyword ALL is used to specify all modules in all directories when searching for MIB files. Every file whose name does not begin with "." is parsed as if it were a MIB file. -M dirlist Specifies a colon-separated list of directories to search for MIBs. This overrides the environment variable MIBDIRS. -T transopts Provides control over the translation of the OID values. The following transopts are available: -Td Display full details of the specified OID. -Tp Display a graphical tree, rooted at the specified OID. -Ta Dump the loaded MIB in a trivial form. -Tl Dump a labeled form of all objects. -To Dump a numeric form of all objects. -Ts Dump a symbolic form of all objects. -Tt Dump a tree form of the loaded MIBs (mostly useful for debugging). -V Display version information for the application and then exit. -w width Specifies the width of -Tp and -Td output. The default is very large. In addition to the preceding options, snmptranslate takes the OID input (-I), MIB parsing (-M) and OID output (-O) options described in the INPUT OPTIONS, MIB PARSING OPTIONS and OUTPUT OPTIONS sections of snmpcmd(1M). Example 1: Expanding sysDescr The following command translates sysDescr to a more qualified form: % snmptranslate -On -IR sysDescr .1.3.6.1.2.1.1.1 The following command does further translation of sysDescr: % snmptranslate -Onf -IR sysDescr .iso.org.dod.internet.mgmt.mib-2.system.sysDescr Again, the following command does further translates sysDescr: % snmptranslate -Td -IR -OS system.sysDescr SNMPv2-MIB::sysDescr sysDescr OBJECT-TYPE -- FROM SNMPv2-MIB -- TEXTUAL CONVENTION DisplayString SYNTAX OCTET STRING (0..255) DISPLAY-HINT "255a" MAX-ACCESS read-only STATUS current DESCRIPTION "A textual description of the entity. This value should include the full name and version identification of the system's hardware type, software operating-system, and networking software." ::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) system(1) 1 } Example 2: Displaying a Tree The following command displays the tree shown below: % snmptranslate -Tp -IR -OS system +--system(1) | +-- -R-- String sysDescr(1) | Textual Convention: DisplayString | Size: 0..255 +-- -R-- ObjID sysObjectID(2) +-- -R-- TimeTicks sysUpTime(3) | | | +-- sysUpTimeInstance(0) | +-- -RW- String sysContact(4) | Textual Convention: DisplayString | Size: 0..255 +-- -RW- String sysName(5) | Textual Convention: DisplayString | Size: 0..255 +-- -RW- String sysLocation(6) | Textual Convention: DisplayString | Size: 0..255 +-- -R-- INTEGER sysServices(7) | Range: 0..127 +-- -R-- TimeTicks sysORLastChange(8) | Textual Convention: TimeStamp | +--sysORTable(9) | +--sysOREntry(1) | Index: sysORIndex(1) | +-- ---- INTEGER sysORIndex(1) | Range: 1..2147483647 +-- -R-- ObjID sysORID(2) +-- -R-- String sysORDescr(3) | Textual Convention: DisplayString | Size: 0..255 +-- -R-- TimeTicks sysORUpTime(4) Textual Convention: TimeStamp Example 3: Dumping MIB Contents The commands shown below produce the dumps that follow. % snmptranslate -Ta | head dump DEFINITIONS ::= BEGIN org ::= { iso 3 } dod ::= { org 6 } internet ::= { dod 1 } directory ::= { internet 1 } mgmt ::= { internet 2 } experimental ::= { internet 3 } private ::= { internet 4 } security ::= { internet 5 } snmpV2 ::= { internet 6 } Here is use of the -Tl option: % snmptranslate -Tl | head .iso(1).org(3) .iso(1).org(3).dod(6) .iso(1).org(3).dod(6).internet(1) .iso(1).org(3).dod(6).internet(1).directory(1) .iso(1).org(3).dod(6).internet(1).mgmt(2) .iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1) .iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).system(1) .iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).system(1).sysDescr(1) .iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).system(1).sysObjectID(2) .iso(1).org(3).dod(6).internet(1).mgmt(2).mib-2(1).system(1).sysUpTime(3) Here is the use of the -To option: % snmptranslate -To | head .1.3 .1.3.6 .1.3.6.1 .1.3.6.1.1 .1.3.6.1.2 .1.3.6.1.2.1 .1.3.6.1.2.1.1 .1.3.6.1.2.1.1.1 .1.3.6.1.2.1.1.2 .1.3.6.1.2.1.1.3 Here is the use of the -Ts option: % snmptranslate -Ts | head .iso.org .iso.org.dod .iso.org.dod.internet .iso.org.dod.internet.directory .iso.org.dod.internet.mgmt .iso.org.dod.internet.mgmt.mib-2 .iso.org.dod.internet.mgmt.mib-2.system .iso.org.dod.internet.mgmt.mib-2.system.sysDescr .iso.org.dod.internet.mgmt.mib-2.system.sysObjectID .iso.org.dod.internet.mgmt.mib-2.system.sysUpTime Here is the use of the -Tt option: % snmptranslate -Tt | head org(3) type=0 dod(6) type=0 internet(1) type=0 directory(1) type=0 mgmt(2) type=0 mib-2(1) type=0 system(1) type=0 sysDescr(1) type=2 tc=4 hint=255a sysObjectID(2) type=1 sysUpTime(3) type=8 0 Successful completion. 1 A usage syntax error. A usage message is displayed. Also used for matching object errors, after which an error message is dis- played. 2 An error occurred while executing the command. An error message is displayed. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWsmcmd | +-----------------------------+-----------------------------+ |Interface Stability |External | +-----------------------------+-----------------------------+ snmpcmd(1M), snmp_variables(4), attributes(5) 21 Jan 2004 snmptranslate(1m)
All times are GMT -4. The time now is 11:03 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy