How to Run a File in Unix
How to Run a File in Unix
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.
Steps

Check that you have permission to run (or) execute the file.

Execute permission is denoted by the letter 'x', while ‘r’ denotes read permission and ‘w’ denotes write permission 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

Execute the file 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.

What's your reaction?

Comments

https://shivann.com/assets/images/user-avatar-s.jpg

0 comment

Write the first comment for this!