Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using FILENAME in awk script

#!/usr/bin/awk -f

{if(!FILENAME) {print "<Gasp.sh> <inputfile>"; exit} calc = 0;....}

I am trying to print out a usage statement in my awk script so if the script is run without an input file, it shows the usage. This is my attempt, but I assume I am not using the FILENAME variable correctly. I also tried putting the if statement in a BEGIN and END block but nothing has worked.

like image 243
John Avatar asked Jan 03 '23 20:01

John


1 Answers

BEGIN{if (ARGC!=2) {print "<Gasp.sh> <inputfile>"; exit} {calc = 0;....}
like image 103
Ed Morton Avatar answered Jan 05 '23 16:01

Ed Morton