How to Create a Unix Executable File

19,896

Well...all you have to do is basically to chmod your file to have executable permissions. For example if you want to create a shell script, you don't need to have .sh or whatever, you just have to write a text file and save it with any name you want, it doesn't even need to have an extension or you can make your own if you want like .bleh just for the fun of it.

For a shell script you just have to write the header (#!/bin/sh) at the beginning of the file, write your code, save it, change permissions to executable and run it with ./yourFileName.bleh.

Share:
19,896

Related videos on Youtube

Arc676
Author by

Arc676

Updated on September 18, 2022

Comments

  • Arc676
    Arc676 over 1 year

    Is it possible to create what the Mac Finder specifies as a "Unix Executable File" and run it in Terminal like any other command instead of creating a .sh or .command file? If so how and where can I learn how to make them? If not, how can I create a .sh file that can take options? For example, with the ls command you can type ls -a to list invisible files as well as visible ones. How can make an executable that will only execute certain code with a -a option?

    • 41754
      41754 over 10 years
      (1) Most probably. (2) using the Internet. (3) with a text editor and following the bash documentation and already asked questions. (4) I would do it with Python's argparse whenever possible, but many other APIs exist. You are off-topic.
    • Arc676
      Arc676 over 10 years
      I don't see how this is off-topic if this forum is about Unix. Tell me how to get on-topic. In response to 2, this forum IS on the internet. If I ask here it probably means I didn't find helpful answers elsewhere...
    • 41754
      41754 over 10 years
      I meant there are many ways to develop Mac OS software... But the point is, forget about Unix Executable Files and just do what you need. If you just want to create a command wrapper for another command, start finding what you need in the Bash manual at GNU and searching throughout Stack Exchange. If you feel constrained by the command interpreter capabilities get to general purpose programming languages, maybe (maybe) priorizing Python.