Created: 2023-04-20 15:35
Status: #idea
Subject: System Administration Programming
Tags: Unix Node Shell Linux
Shebang
A shebang is used to tell the Operating System what kind of Interpreter should be used to run the script.
#!/usr/bin/bash
echo "I'm being ran with bash!"
# this only works on Unix-based systems
./index.js
# we have to use the node command in Windows
node index
Finding the Proper Shebang Directory
With the Bash
which
command, we can find the location of any executable.
$ which bash && which node && which python
/usr/bin/bash
/c/Program Files/nodejs/node
/c/Users/LENOVO/AppData/Local/Programs/Python/Python310/python
#!/c/Users/LENOVO/AppData/Local/Programs/Python/Python310/python
print("I'm being ran from Python!");
/* index.js */
#!/usr/bin/env node
console.log("I'm being ran with Node.js!");