Bash
1
# Check if command is in PATH
2
checkDep() {
3
path=`command -v ${1}` && echo "${1} found at ${path}" || { echo "${1} not found" >&2 ; exit 1; }
4
}
Copied!
1
# Get output of command. https://www.cyberciti.biz/faq/unix-linux-bsd-appleosx-bash-assign-variable-command-output/
2
# i.e. save output of date to var now
3
now=$(date)
Copied!
1
File testing
2
​
3
![](https://i.imgur.com/QGkHbPm.png)
Copied!
1
# Pipe output to file.
2
# i.e. pipe output of ls to output.txt
3
ls > output.txt
Copied!
1
# Check if no arguments passed
2
if [ $# -eq 0 ] then ... fi
Copied!
1
# Check if file does not exist
2
# Putting ! before makes it a not statement. Spaces before and after [] are important.
3
if [ ! -f ~/Desktop/file.txt ]; then
4
echo "File not found!"
5
fi
Copied!
1
# Source vs ./
2
# Runs the script as an executable file, launching a new shell to run it
3
./script
4
​
5
# Reads and executes commands from filename in the current shell environment
6
source script
Copied!
1
# need to wrap the cd command inside () to run it in scope of the cd
2
# i.e. pod install will be run inside ios dir
3
(cd ios && pod install)
Copied!
Last modified 1yr ago
Copy link