An avid Linux tinkerer, been using Linux for 4 years · Author has 587 answers and 805.8K answer views · 6y ·
As a demonstration of the point made clear by the existing answers I would like to add an example.
- #!/bin/sh
- sleep 50
let’s save it as a.sh
and make it executable
- sudo chmod +x a.sh
Let's run it in the background and stat the process.
- ./a.sh&
- [1] 11660
On looking at the process details:
- ps -fp 11660
- UID PID PPID C STIME TTY TIME CMD
- sudipbh+ 11660 11330 0 15:30 pts/7 00:00:00 /bin/sh ./a.sh
We can see that the content of the file is passed as an argument to the program /bin/sh.
In Bash scripting, this enables the script author to mention the exact interpreter to be used by the program and if it’s not found the user can take it as a cue to install the required interpreter.
The same idea would be extended to other interpreted languages like python.
282 views ·
1 of 12 answers
Something went wrong. Wait a moment and try again.