This question already has an answer here:

I want to know how to make a program that you can edit and run. The problem is I don't know what the file extension is, like how you can make a text document on windows and save as filename.bat.

marked as duplicate by mikewhatever, Jacob Vlijm, karel, muru, Eric Carvalho Apr 17 '17 at 23:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I am a little unclear here. You want to make a program with Ubuntu but you want it to be a batch file you can run on Windows? – John Apr 16 '17 at 2:14
  • 2
    I think what you're looking for are shell scripts, with file extension .sh see bash.cyberciti.biz/guide/Hello,_World!_Tutorial – brndn2k Apr 16 '17 at 2:17
  • 1
    Like echo -e '#!/bin/bash\necho this is a script' > script.sh; chmod +x script.sh ? Then run it ./script.sh ? – Xen2050 Apr 16 '17 at 5:51
  • @brndn2k see here – jarno Apr 16 '17 at 6:13
  • no, I was wondering if I could write code in a text doc within Ubuntu then run it in Ubuntu LIKE a windows batch file – TheWorstPvPer May 25 '17 at 23:11

You do not have to use a filename extension, but the file permission has to be set executable for the user who should be able to run it (unless you source a file in shell). See man chmod.

By using a shebang you can tell which interpreter to use to execute a script.

Not the answer you're looking for? Browse other questions tagged or ask your own question.