Erik Fredericks, frederer@gvsu.edu Fall 2025
Based on material provided by Erin Carrier, Austin Ferguson, and Katherine Bowers
Easy mode: a series of bash commands run in order
However, bash is a full programming language!
Examples!
git
Basically, we're going to put all the bash commands we know into a file
Convention is to use a .sh extension
.sh
bash file.sh
Make it executable?
chmod u+x filename
chmod +x filename
./filename
(The top line telling your script where to find bash)
bash
#!/bin/bash
#!/usr/bin/env bash
Can use with others like Python:
#!/usr/bin/env python3
/usr/bin/env vs. /bin/bash
/usr/bin/env
/bin/bash
env
$PATH
brew install bash
#!/usr/local/bin/bash
# begins a comment until the end of the line
#
Exception:
Ex:
#!/bin/bash echo "Hello there" # this is also a comment # this is a comment