PDF download Download Article PDF download Download Article

You can run a file in UNIX by invoking the file name from the command line. Alternatively, you can also choose to invoke a specific shell to run the file.

    • If you are the owner of the file, you can grant yourself execute permission by using the ‘chmod’ command. Below example shows the file ‘file.sh’ before and after granting execute permission
    Advertisement
    • To execute the file, go to the directory where the file is and then invoke the file using the relative path.
    • Or, you can also execute the file using the full path or absolute path.
    • Sometimes, you may want to execute the file in a different shell in order to obtain the special behaviour of that shell. In such cases, the specified shell will start as a subshell of your current shell and execute the file. In the example below, we have executed the file.sh first using the BASH shell, then using the C shell and finally, using the KORN shell.
  1. Advertisement

Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement

Video

Tips

  • Standard UNIX file naming convention for executable or runnable files is to suffix the file name with “.sh”
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
Advertisement

Warnings

  • Each shell has its own syntax for variables, functions, arguments etc. So make sure that the shell you are using to run your file is the right one for the job.
Advertisement

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, volunteer authors worked to edit and improve it over time. This article has been viewed 37,043 times.
How helpful is this?
Co-authors: 7
Updated: December 23, 2024
Views: 37,043
Categories: File Sharing
Thanks to all authors for creating a page that has been read 37,043 times.

Is this article up to date?

Advertisement