awk regex doesn't work when match ip address

I wanna extract ip address in a file, each line of the file is like:

T 7   2719    1378473670  N   0   0   0   G   0   I,0.146,1,0.239,1,0.182,1,0.210,1,0.676,1,39.287,1,39.335,1,50.128,1,42.917,1,188.165,1,201.100,1,194.939,1,194.915,1,237.396,1,251.547,1,260.946,1,256.046,1,245.145,1,241.663,1   q   q   q,283.784,1;,284.763,1

But my awk script doesn't work

#!/usr/bin/awk -f
    FS = "[, \t;]"
    for(i = 4; i <= NF; i++) 
        if ($1 == "#")
        if ($i ~ /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/)
            printf $i"\t"
        if (i == NF) 
            printf "\n"

Can anyone figure out what's wrong?

Any help will be really appreaciated, thanks in advance.

PS: there is no output but a new line character


Try this awk

awk -F"[, \t;]+" '!/^#/ {for (i=1;i<NF;i++) if ($i ~ /(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/) printf "%s\t",$i;print ""}' file

This !/^#/ makes it only prints line not starting with #

Need Your Help

Ofbiz service creation

java ofbiz

Starting to learn ofbiz, I am following the tutorial here:

Passing stdout colored output to grunt output

javascript node.js gruntjs

I'm trying to create a grunt custom task that runs mocha tests but I can't figure out how to have grunt take the colored output from mocha and display it as it does when running the mocha command

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.