How to print exit status in AWK

Hi all,

How can I print the exit status in AWK?

echo $? doesnt work for me

Thanks

Awk has an exit command (or statement, call it what you will)..

$ echo blah | awk '{exit 13}'
$ echo $?
13

Or did you mean something else?

$ #!/bin/nawk -f
$ BEGIN { FS=",";

$ if (ARGC ==1)
$ {print "You need 2 arguments on the command line"}
$ echo "Error" | awk '{exit 13}'
$ echo $?

$ }

How do i have an exit status returned when the number of commandline arguments is 1. The above script does not work

$ cat Test
#!/usr/bin/awk -f
BEGIN { FS=",";
  if (ARGC != 3) {
   print "You need 2 arguments on the command line"
   exit 13
  }
}

$ ./Test
You need 2 arguments on the command line
$ echo $?
13
$ ./Test 1
You need 2 arguments on the command line
$ echo $?
13
$ ./Test 1 2
$ echo $?
0

Thanks.That works.