# Executing a .m file from the Linux command line

I have some code in a file named Demo-3.m, It can be evaluated in Mathematica 9. The final expression in the file is

Export[NotebookDirectory[] <> "fintempimg.jpg", fintempimg];


How can I execute Demo-3.m in Linux using the command-line? Please give me a solution with an example.

-
I think you can use script to do this, like math -script file.m. Here has very useful step by step detail. – xslittlegrass Feb 25 '13 at 2:46
Oh my god!! thanks for @xslittlegrass solution, it can work :) – Darren Lee Feb 25 '13 at 2:54

As xslittlegrass posted in a comment to the question, the file Demo-3.m can be run on Linux by issuing

math -script Demo-3.m


at the command line.