By rveri
Experts,
In one example I have seen how to get output upto 3rd octet, when there is a “:” separated with the 4rth octet.
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,
…read more
Source: FULL ARTICLE at The UNIX and Linux Forums

Add to favorites 