Sponsored Content
Top Forums Shell Programming and Scripting Awk: Help with how to remove 4rth octet : Post 302771177 by rveri on Tuesday 19th of February 2013 11:44:16 PM
Old 02-20-2013
Awk: Help with how to remove 4rth octet :

Experts,
In one example I have seen how to get output upto 3rd octet, when there is a ":" separated with the 4rth octet.

However in this example how to remove 4rth octet and to keep upto 3rd octet with regular expressions and awk sub function:

I have tried with :but not working:
Code:
# awk '{ sub(/\.[0-9]+[ ]/,x,$3); print $2,$3}' file


Code:
HOST= cmiHOST06    10.26.107.73 /data120 /nbu/cmiHOST06/athpx07/aa1
HOST= cmiHOST05    10.26.12.76 /data120 /nbu/cmiHOST05/athpx07/cc1
HOST= cmiHOST05    10.26.1.75 /data120 /nbu/cmiHOST05/athpx07/dd1



output should be look like:
Code:
cmiHOST06 10.26.107
cmiHOST05 10.26.12
cmiHOST05 10.26.1


Thanks a lot,
 

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
shishi_pbkdf2_sha1(3)						      shishi						     shishi_pbkdf2_sha1(3)

NAME
shishi_pbkdf2_sha1 - API function SYNOPSIS
#include <shishi.h> int shishi_pbkdf2_sha1(Shishi * handle, const char * P, size_t Plen, const char * S, size_t Slen, unsigned int c, unsigned int dkLen, char * DK); ARGUMENTS
Shishi * handle shishi handle as allocated by shishi_init(). const char * P input password, an octet string size_t Plen length of password, an octet string const char * S input salt, an octet string size_t Slen length of salt, an octet string unsigned int c iteration count, a positive integer unsigned int dkLen intended length in octets of the derived key, a positive integer, at most (2^32 - 1) * hLen. The DK array must have room for this many characters. char * DK output derived key, a dkLen-octet string DESCRIPTION
Derive key using the PBKDF2 defined in PKCS5. PBKDF2 applies a pseudorandom function to derive keys. The length of the derived key is essentially unbounded. (However, the maximum effective search space for the derived key may be limited by the structure of the underlying pseudorandom function, which is this function is always SHA1.) RETURN VALUE
Returns SHISHI_OK iff successful. REPORTING BUGS
Report bugs to <bug-shishi@gnu.org>. COPYRIGHT
Copyright (C) 2002-2010 Simon Josefsson. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. SEE ALSO
The full documentation for shishi is maintained as a Texinfo manual. If the info and shishi programs are properly installed at your site, the command info shishi should give you access to the complete manual. shishi 1.0.1 shishi_pbkdf2_sha1(3)
All times are GMT -4. The time now is 05:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy