Hi all.
I have a simple shell script shown below which calls an awk function and then print valid or invalid depending on the return value:
#!/bin/sh
cat file.CSV| nawk -f validate '
BEGIN { FS=","; counter=0}
{
FS=",";
gsub("\"","")
valid=validate($1);
if (valid == 1)
print "INVALID";
else
print "VALID"
}
When i run this script I get no output at all. The script runs but nothing seems to happen. However when i include the function, shown below, in the script it runs as expected.
function validate(object)
{
#populates an array List
if(object in stationList){
return 0;}
else{
return 1;}
}
I dont want to have to include the functions code in every script I write and I was under the impression that using -f validate when starting nawk would let me then call the function from within my script.
Any ideas or help with this would be appreciated.
Thanks