~2 min read|
I am constantly striving to improve my understanding and comfort interacting with my terminal. I remember how excited I was when I first started to understand how to change my shell from bash to zsh, create persistent aliases, and even begin writing my own functions.
More recently, I’ve been experimenting writing shell scripts when it dawned on me - I didn’t actually know how to run the script. If it were an
.html file, I could open it in a web browser. If it were a node application, I could run it from the command line:
$ node my-file.js
But what about a
This is one of those questions that once you know how, you forget that you once didn’t. But until you know - it’s not really clear what you’d do.
Imagine you have a directory with a
setup script in it:
. ├── node_modules ├── package-lock.json ├── package.json ├── setup.sh └── src
To execute the setup script, you simply call it:
In this example, I’m already in the directory where setup lives - but you can imagine if I was up a directory, and it was saved in a directory
scripts, I could also call it:
You don’t need to preface it with anything (as in the
node example) because the shell knows how to execute the shell script!
Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!