Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
General
cancel
Showing results for
Did you mean:

## please check the syntax of this script

Occasional Contributor

## please check the syntax of this script

BEGIN{
FS="|";
}
{

if(\$26 < 0){na=na+1};
else if (\$26 > 0) && (\$26 <= 10) {nb = nb+1};
else if (\$26 >10) && (\$26<20) {nc = nc+1};
else if (\$26 > 20) && (\$26 < 30) {nd = nd+1};
esle if (\$26 > 30) && (\$26 < 40) {ne = ne+1};
else if (\$26 > 40) && (\$26 < 50) {nf = nf+1};
esle (\$26 > 50) {ng=ng+1} }
END {print na, nb, nc, nd, ne, nf, ng, nh, ni, nj}
2 REPLIES
Honored Contributor

## Re: please check the syntax of this script

The problem is the ";"

The middle part should be:

if(\$26 < 0){na=na+1}
else if (\$26 > 0) && (\$26 <= 10) {nb = nb+1}
else if (\$26 >10) && (\$26<20) {nc = nc+1}
else if (\$26 > 20) && (\$26 < 30) {nd = nd+1}
esle if (\$26 > 30) && (\$26 < 40) {ne = ne+1}
else if (\$26 > 40) && (\$26 < 50) {nf = nf+1}
esle (\$26 > 50) {ng=ng+1} }

"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Honored Contributor

## Re: please check the syntax of this script

There is no coverage of 20, 30, 40, and 50
There are far too many semi-colons

if (\$26 < 0) { na = na + 1 }
else if (\$26 < 10) { nb = nb + 1 }
else if (\$26 < 20) { nc = nc + 1 }
:
:
else { ng = ng + 1 }

or in perl

\$n[\$F[25]<0?0:\$F[25]>50?7:1+int(\$F[25]/10)]++;
END{print @n[0..7]}

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn