Solved

splitting octets with awk

Posted on 2013-01-25
6
274 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Utilizing an array to gracefully append to a list of EmailAddresses
Fine Tune your automatic Updates for Ubuntu / Debian
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now