Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

awk shebang doesn't work

I have a simple awk program:

#!/usr/bin/awk -f
BEGIN {print "work already!"}

If I run it as:

awk -f panic

on the (osx) terminal it works. But it fails if I try running it as a script:

. panic
-bash: BEGIN: command not found

I checked the location of awk using which awk and it is indeed located at /usr/bin/awk. Any ideas why it isn't working?

like image 440
hba Avatar asked Jan 15 '23 16:01

hba


1 Answers

Run it as ./panic, not . panic , as the latter is the same as running source panic, which won't do what you want. See man source

like image 103
Justin Lewis Avatar answered Jan 20 '23 07:01

Justin Lewis