Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

splitting octets with awk

Posted on 2013-01-25
6
Medium Priority
?
294 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 400 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 400 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 400 total points
ID: 38820042
Did you try this?

awk -F\. '{print $1 "\n" $2 "\n" $3 "\n" $4}
0
Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

 
LVL 79

Assisted Solution

by:arnold
arnold earned 400 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 400 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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

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 …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

705 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