Talk:Program name: Difference between revisions

Content added Content deleted
(The awk solution does not work for me)
Line 34: Line 34:
The awk solution does not work for me. I pasted the code into an executable script file test.awk as follows:
The awk solution does not work for me. I pasted the code into an executable script file test.awk as follows:


#!/usr/bin/awk
#!/usr/bin/awk
BEGIN {
BEGIN {
"ls" | getline file
"ls" | getline file
close("ls")
close("ls")
print "This file is " file
print "This file is " file
}
}


I then run my script test.awk as follows:
I then run my script test.awk as follows:
Line 50: Line 50:


[[User:Markhobley|Markhobley]] 12:14, 6 September 2011 (UTC)
[[User:Markhobley|Markhobley]] 12:14, 6 September 2011 (UTC)

Ahhh, I fixed the hashbang:

#!/usr/bin/awk -f

It still didn't work though, because it gives the wrong filename:

$ ./test.awk
This file is keyring-QoRJiR

It should read "This file is test.awk".

[[User:Markhobley|Markhobley]] 12:17, 6 September 2011 (UTC)