Output source file name [duplicate]

Write a program that prints the name of its source file. REPL environments are not allowed for this challenge. Your code must work in any file that your language's interpreter will accept. Your answer must also be a full program, not just a function. The source code's file extension must be printed. Leading or trailing newline are both optional. This is a code golf, so shortest answer wins. The winner will be chosen on September 2nd, 2016.

• Possibly dupe of the cheating quine challenge? Idk though. Aug 26, 2016 at 16:39
• @Mego that question asks to actually reverse the charge filename in the file system. This is just printing the file name. So not a duplicate Aug 26, 2016 at 17:01
• @vikarjramun Reading the file name is a significant part of the challenge. This is a trivial subset of that challenge.
– user45941
Aug 26, 2016 at 17:01

V, 3 bytes

"zp


Try it online!

This actually does work in the online interpreter somehow. ¯\_(ツ)_/¯

Explanation:

The 'z' register is predefined to the source file of the program, and p pastes from whatever register you tell it to. P would also work, and not cause any different output.

Bash, 7

echo \$0


So trivial, I have to type in this text to make the answer long enough.

C, 23 bytes

main(){puts(__FILE__);}


Try it on Ideone