Skip to main content


It's very useful to use ShellCheck to check any shell code you write.


  • The proper she-bang for Bash is #!/usr/bin/env bash.


# Check if command is in PATH
checkDep() {
path=`command -v ${1}` && echo "${1} found at ${path}" || { echo "${1} not found" >&2 ; exit 1; }
# Get output of command.
# i.e. save output of date to var now
File testing

# Pipe output to file.
# i.e. pipe output of ls to output.txt
ls > output.txt
# Check if no arguments passed
if [ $# -eq 0 ] then ... fi
# Check if file does not exist
# Putting ! before makes it a not statement. Spaces before and after [] are important.
if [ ! -f ~/Desktop/file.txt ]; then
echo "File not found!"
# Source vs ./
# Runs the script as an executable file, launching a new shell to run it

# Reads and executes commands from filename in the current shell environment
source script
# need to wrap the cd command inside () to run it in scope of the cd
# i.e. pod install will be run inside ios dir
(cd ios && pod install)