Chapter 10
Bash: an introduction
Updated July 3, 2026
So far you have typed commands one at a time. When a sequence of ten commands repeats every day, it is time to save it in a file. That file is a script, and Bash reads it the same way it reads the lines you type by hand.
A script is an ordinary text file. To tell the system which program runs it, the first line starts with a shebang:
#!/usr/bin/env bash
echo "hello from a script"The line #!/usr/bin/env bash finds bash through PATH instead of hard-coding a path like /bin/bash. To run the file as a program, it needs the execute bit:
$ chmod +x hello.sh # allow execution
$ ./hello.sh # run it from the current directoryVariables and quoting
A variable hold
Locked
The rest of this chapter is part of a paid course
You are reading the open part. Buy the course to read the whole chapter.