Bash parameter manipulation
I'm a great fan of using the Linux command line and enjoy writing shell scripts using the Bash shell.
BASH (or more usually Bash or bash) is the name of a Unix shell. The name stands for Bourne Again SHell, which is a play on words. Bash is an extension of the shell originally written by Stephen Bourne in 1978, usually known as SH.
A shell is the part of the operating system that interprets commands, more commonly known as the command line.
A knowledge of Bash is very helpful if you would like to be able to use the power of the command line. It is also the way to learn how to build Bash scripts for automating the tasks you need to perform.
In this episode we look at what parameters are in Bash, and how they can be created and manipulated. There are many features in Bash that you can use to do this, but they are not easy to find.
As I was learning my way around Bash it took me a while to find these. Once I had found them I wanted to make a "cheat sheet" I could stick on the wall to remind me how to do things. I am sharing the result of this process with you.
The version of Bash which I used for this episode is 4.3.30(1)-release
The full notes for this episode are to be found here: http://hackerpublicradio.org/eps/hpr1648_full_notes.html
- Shell Parameter Expansion http://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
- Bash Hackers on parameter expansion http://wiki.bash-hackers.org/syntax/pe
- Previous HPR shows on the shell or shell scripting:
- 2008-03-03 HPR0045: Shell Scripting (dosman) http://hackerpublicradio.org/eps.php?id=45
- 2008-03-12 HPR0052: UCLUG: Newbie Shell Scripting (Dave Yates) http://hackerpublicradio.org/eps.php?id=52
- 2010-03-24 HPR0531: bash loops (Ken Fallon) http://hackerpublicradio.org/eps.php?id=531
- 2010-08-11 HPR0562: Introduction to bash scripting (Ken Fallon) http://hackerpublicradio.org/eps.php?id=562
- 2010-11-17 HPR0598: Bash Scripting: Episode 2 Command Line Basics (Ken Fallon) http://hackerpublicradio.org/eps.php?id=598
- 2012-05-22 HPR0992: Linux In The Shell 007 - Chmod and Unix Permissions. (Dann) http://hackerpublicradio.org/eps.php?id=992
- 2012-06-05 HPR1002: Linux In The Shell 008 - free: Understanding Linux Memory Usage (Dann) http://hackerpublicradio.org/eps.php?id=1002
- 2013-03-05 HPR1197: What I do with bash scripts (Jon Kulp) http://hackerpublicradio.org/eps.php?id=1197
- 2013-04-09 HPR1222: LiTS 027: mathematical commands (Dann) http://hackerpublicradio.org/eps.php?id=1222
- 2013-05-14 HPR1247: Recording Terrestrial Radio with bash scipts and cron jobs (Jon Kulp) http://hackerpublicradio.org/eps.php?id=1247
- 2013-05-22 HPR1253: Linux in the Shell Ep 30 - vmstat (Dann) http://hackerpublicradio.org/eps.php?id=1253
- Full show notes http://hackerpublicradio.org/eps/hpr1648_full_notes.html
- Bash man page extract http://hackerpublicradio.org/eps/hpr1648_summary.pdf
- Parameter manipulation "cheat sheet" http://hackerpublicradio.org/eps/hpr1648_diagram.pdf
- Various annotated Bash scripts which make up my Magnatune Downloader (described in show hpr1204) https://gitorious.org/magnatune-downloader/magnatune-downloader/source/master: