Collection of scripts and resources gathered through the process of learning bash.
This work is by no means complete and is written from a bash beginner's perspective. It assumes the viewer is familiar with programming and is comfortable in a terminal window but has little to no bash experience.
Examples are organized by tool or concept. Scripts are written and known to work using GNU bash version 3.2.48 (default OSX 10.6 installation).
Topics (ordered alphabetically)
- awk
- basic
- break
- case
- continue
- expansion
- expressions
- for
- ls
- pipes
- printf
- read
- redirection
- sed
- strings
- tests
- until
- while
Best method of using the examples is to open the file to view the source comments followed by running the file in terminal to see the results. Some examples are explained in comments and others in the output so check both.
Links, Books, & everthing else
bash-bp - BASH Executable Boilerplate
A helper for creating a new (executable) bash file.
Usage:
bash-bp -h
Example:
$ bash-bp -f mytool
Check to make sure the file was created:
$ cat mytool
#!/bin/bash
# code goes here
Make sure it's executable:
$ test -x mytool && echo true || echo false
true
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License