Solved

splitting octets with awk

Posted on 2013-01-25
6
277 Views
Last Modified: 2013-01-27
I  have a ip address  Quad=10.20.30.40

with awk I want to print this out
10
20
30
40

awk -F.     is not working for me.
0
Comment
Question by:TIMFOX123
6 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 100 total points
ID: 38820025
Quad=10.20.30.40
echo $Quad | awk -F. '{for( i=1;i<=NF; ++i){ print $i}}'
0
 
LVL 31

Assisted Solution

by:farzanj
farzanj earned 100 total points
ID: 38820033
Works for me
echo 10.20.30.40 | awk -F. '{print $1"\n"$2"\n"$3"\n"$4}'
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 100 total points
ID: 38820042
Did you try this?

awk -F\. '{print $1 "\n" $2 "\n" $3 "\n" $4}
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 77

Assisted Solution

by:arnold
arnold earned 100 total points
ID: 38820045
echo QUAD | awk -F\. ' (NF == 4  { print $1"\n"$2"\n"$3"\n"$4"\n" } '

NF is the equal to the number of elements. If there are not the four octets, there will be no output.

. ' " , etc. have to be escaped (\) when those are the delimeter.
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 100 total points
ID: 38821350
Do you have to use awk?

If not, easier to do

echo 10.20.30.40|tr '.' '\n'

Open in new window

0
 

Author Closing Comment

by:TIMFOX123
ID: 38825223
Everybody did such a great job

ozo has the answer I used.

tintin, your answer just rocks !!
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question