Sponsored Content
Top Forums Shell Programming and Scripting Awk: Help with how to remove 4rth octet : Post 302771216 by RudiC on Wednesday 20th of February 2013 03:48:52 AM
Old 02-20-2013
Your awk program were working fine if you searched for the end of $3, represented by "$", instead of looking for whitespace which, being the field separator, was stripped off:
Code:
$ awk '{ sub(/\.[0-9]+$/,x,$3); print $2,$3}' file
cmiHOST06 10.26.107
cmiHOST05 10.26.12
cmiHOST05 10.26.1

This User Gave Thanks to RudiC 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
IMAGE_TYPE_TO_MIME_TYPE(3)						 1						IMAGE_TYPE_TO_MIME_TYPE(3)

image_type_to_mime_type - Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype

SYNOPSIS
string image_type_to_mime_type (int $imagetype) DESCRIPTION
The image_type_to_mime_type(3) function will determine the Mime-Type for an IMAGETYPE constant. PARAMETERS
o $imagetype - One of the IMAGETYPE_XXX constants. RETURN VALUES
The returned values are as follows Returned values Constants +----------------------------------------+-------------------------------+ | $imagetype | | | | | | | Returned value | | | | +----------------------------------------+-------------------------------+ | | | | IMAGETYPE_GIF | | | | | | | | | | image/gif | | | | | | | | IMAGETYPE_JPEG | | | | | | | | | | image/jpeg | | | | | | | | IMAGETYPE_PNG | | | | | | | | | | image/png | | | | | | | | IMAGETYPE_SWF | | | | | | | | | | application/x-shockwave-flash | | | | | | | | IMAGETYPE_PSD | | | | | | | | | | image/psd | | | | | | | | IMAGETYPE_BMP | | | | | | | | | | image/bmp | | | | | | | | IMAGETYPE_TIFF_II (intel byte order) | | | | | | | | | | image/tiff | | | | | | | |IMAGETYPE_TIFF_MM (motorola byte order) | | | | | | | | | | image/tiff | | | | | | | | IMAGETYPE_JPC | | | | | | | | | | application/octet-stream | | | | | | | | IMAGETYPE_JP2 | | | | | | | | | | image/jp2 | | | | | | | | IMAGETYPE_JPX | | | | | | | | | | application/octet-stream | | | | | | | | IMAGETYPE_JB2 | | | | | | | | | | application/octet-stream | | | | | | | | IMAGETYPE_SWC | | | | | | | | | | application/x-shockwave-flash | | | | | | | | IMAGETYPE_IFF | | | | | | | | | | image/iff | | | | | | | | IMAGETYPE_WBMP | | | | | | | | | | image/vnd.wap.wbmp | | | | | | | | IMAGETYPE_XBM | | | | | | | | | | image/xbm | | | | | | | | IMAGETYPE_ICO | | | | | | | | | | image/vnd.microsoft.icon | | | | +----------------------------------------+-------------------------------+ EXAMPLES
Example #1 image_type_to_mime_type(3) example <?php header("Content-type: " . image_type_to_mime_type(IMAGETYPE_PNG)); ?> NOTES
Note This function does not require the GD image library. SEE ALSO
getimagesize(3), exif_imagetype(3), exif_read_data(3), exif_thumbnail(3). PHP Documentation Group IMAGE_TYPE_TO_MIME_TYPE(3)
All times are GMT -4. The time now is 11:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy