tags:

views:

48

answers:

2

Hello,

when I call my awk script, I keep getting an error :

sam@sam-laptop:~/shell/td4$ awk -f agenda.awk -- -n Robert agenda.txt
awk: agenda.awk:6: printf "Hello"
awk: agenda.awk:6: ^ syntax error

the script contains this :

#!/usr/bin/awk
BEGIN {
}

printf "Hello"

END {
}

Thank you

+3  A: 
ocdcoder
Hi,thanks, but now i'm getting this error : awk: fatal: cannot open file `-n' for reading (No such file or directory)
Samantha
i'm not sure what you are trying to do with the -- and -n Robert, but if you want to use agenda.txt as the source input just do: awk -f agenda.awk agenda.txt
ocdcoder
with $awk -f agenda.awk agenda.txt it works fine, but i want to add command line arguments to my awk script.. so that my program searchs the agenda for a name with -n or an e-mail with -m... How do I do that ? Thank you !
Samantha
adding arguments you use the "-v" option like so: awk -f agenda.awk -v name=Robert -v [email protected] agenda.txt
ocdcoder
works great thank you !
Samantha
glad to help :-) awk is my favorite language
ocdcoder
A: 

i think you also need to modify the shebang as

#!/usr/bin/awk -f
alvin