splitting octets with awk

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

with awk I want to print this out

awk -F.     is not working for me.
Question by:TIMFOX123
LVL 84

Accepted Solution

ozo earned 100 total points
Comment Utility
echo $Quad | awk -F. '{for( i=1;i<=NF; ++i){ print $i}}'
LVL 31

Assisted Solution

farzanj earned 100 total points
Comment Utility
Works for me
echo | awk -F. '{print $1"\n"$2"\n"$3"\n"$4}'
LVL 68

Assisted Solution

woolmilkporc earned 100 total points
Comment Utility
Did you try this?

awk -F\. '{print $1 "\n" $2 "\n" $3 "\n" $4}
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

LVL 76

Assisted Solution

arnold earned 100 total points
Comment Utility
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.
LVL 48

Assisted Solution

Tintin earned 100 total points
Comment Utility
Do you have to use awk?

If not, easier to do

echo|tr '.' '\n'

Open in new window


Author Closing Comment

Comment Utility
Everybody did such a great job

ozo has the answer I used.

tintin, your answer just rocks !!

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

771 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

7 Experts available now in Live!

Get 1:1 Help Now