Sponsored Content
Top Forums Shell Programming and Scripting Awk: Help with how to remove 4rth octet : Post 302771183 by zazzybob on Wednesday 20th of February 2013 01:19:59 AM
Old 02-20-2013
Using sed:

Code:
$ sed 's/^[^=]*= \([^ ]*\)[ ]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)\..*$/\1 \2/' foo.txt 
cmiHOST06 10.26.107
cmiHOST05 10.26.12
cmiHOST05 10.26.1

Cheers,
ZB
This User Gave Thanks to zazzybob For This Post:
 

5 More Discussions You Might Find Interesting

1. Programming

ip address octet increments

Hi all, Situation is as below. I would get an IP address and port from eithe r a file or command line. It probably would be as char * or string. So was wondering how I could accept this and increment the last octets? Incrementing the port is fine. I could get that into an integer by atoi()... (8 Replies)
Discussion started by: Naanu
8 Replies

2. UNIX and Linux Applications

Any idea on 3 Octet IP address ?

Hi All, I found my weblog contain entries like 121.23.3 Instead of four octet. I am quite confused is it possible to have 3 octet ip at all ?? Is it generating by any program and hittng the website ? Is it a subdomain ? Please tell me your understanding on it ? Thanks (4 Replies)
Discussion started by: jambesh
4 Replies

3. UNIX for Dummies Questions & Answers

What is an (application/octet-stream) file?

I'm trying to learn as much about GRUB as I can and it's stages are stored in these types of files. Any info or search terms is appreciated!:wall: (5 Replies)
Discussion started by: theKbStockpiler
5 Replies

4. Shell Programming and Scripting

awk Quick Help: printing upto 3rd octet .

Hi Experts, I am trying to print $2 & the IP_address upto 3rd octet only. But unable to do so, Trying # awk '{print $2, substr($4,1,9)}' file . but not correct File: HOST= cmiHOST06 :: 10.26.107.73:/data120 /nbu/cmiHOST06/athpx07/aa1 HOST= cmiHOST05 :: 10.26.12.76:/data120... (5 Replies)
Discussion started by: rveri
5 Replies

5. Shell Programming and Scripting

Bash subtract fourth octet of an IP by 1

Hello, Im looking to help out my team by automating a simple search list. The user will look for a peering ip /30. For example 192.168.1.2/30 and gets the result. Im trying to get the entered /30 and subtract the last octet by one. echo -n "Enter peering ip : "; read peeringip cat... (3 Replies)
Discussion started by: D'go
3 Replies
SNMPTEST(1)							     Net-SNMP							       SNMPTEST(1)

NAME
snmptest - communicates with a network entity using SNMP requests SYNOPSIS
snmptest [COMMON OPTIONS] DESCRIPTION
snmptest is a flexible SNMP application that can monitor and manage information on a network entity. After invoking the program, a command line interpreter proceeds to accept commands. It will prompt with: Variable: At this point you can enter one or more variable names, one per line. A blank line is a command to send a request for each of the vari- ables (in a single packet) to the remote entity. Each variable name is given in the format specified in variables(5). For example: snmptest -c public -v 1 zeus Variable: system.sysDescr.0 Variable: will return some information about the request and reply packets, as well as the information: requestid 0x5992478A errstat 0x0 errindex 0x0 system.sysDescr.0 = STRING: "Unix 4.3BSD" Upon startup, the program defaults to sending a GET request packet. This can be changed to a GETNEXT request or a SET request by typing the commands "$N" or "$S" respectively. Typing "$G" will go back to the GET request mode. The command "$D" will toggle the dumping of each sent and received packet. The command "$QP" will toggle a quicker, less verbose output form. When in the "SET request" mode, more information is requested by the prompt for each variable. The prompt: Type [i|s|x|d|n|o|t|a]: requests the type of the variable be entered. Type "i" for an integer, "s" for an octet string in ASCII, "x" for an octet string as hex bytes separated by whitespace, "d" for an octet string as decimal bytes separated by whitespace, , "a" for an ip address in dotted IP nota- tion, and "o" for an object identifier. At this point a value will be prompted for: Value: If this is an integer value, just type the integer (in decimal). If it is a decimal string, type in white-space separated decimal numbers, one per byte of the string. Again type a blank line at the prompt for the variable name to send the packet. At the variable name line, typing "$Q" will quit the program. OPTIONS
snmptest takes the common options described in the snmpcmd(1) manual page. SEE ALSO
snmpcmd(1), snmpget(1), snmpset(1), variables(5) 4th Berkeley Distribution 08 Feb 2002 SNMPTEST(1)
All times are GMT -4. The time now is 10:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy