I have a function that looks at every number in a file, checks if it is a perfect square, and if it is, increments a counter by 1. The goal of the function is to count the total number of perfect squares.
awk 'function root(x)
{if (sqrt(x) == int(sqrt(x))) count+=1 }
{print root($1)}
END{print count}' numbers_1k.list
The output from this code gives a blank line for each time it checked the condition on a line of the file. So if the file has 1000 lines, its 1000 blank lines in the output followed by the variable count
Is there anyway to avoid this? I have checked previous similar questions.