hpr1648 :: Bash parameter manipulation
A summary and aide memoire of Bash parameter expansion methods
Hosted by Dave Morriss on Wednesday, 2014-11-26 is flagged as Explicit and is released under a CC-BY-SA license.
Bash, script, parameter, variable.
8.
The show is available on the Internet Archive at: https://archive.org/details/hpr1648
Listen in ogg,
spx,
or mp3 format. Play now:
Duration: 00:40:33
Bash Scripting.
This is an open series in which Hacker Public Radio Listeners can share their Bash scripting knowledge and experience with the community. General programming topics and Bash commands are explored along with some tutorials for the complete novice.
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.
Bash was written as part of the GNU Project which forms part of the Linux Operating System.
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: hpr1648_full_notes.html
Links
- Definitions:
- References
- Shell Parameter Expansion https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
- Bash Hackers on parameter expansion https://wiki.bash-hackers.org/syntax/pe
- Previous HPR shows on the shell or shell scripting:
- 2008-03-03 HPR0045: Shell Scripting (dosman) hpr0045
- 2008-03-12 HPR0052: UCLUG: Newbie Shell Scripting (Dave Yates) hpr0052
- 2010-03-24 HPR0531: bash loops (Ken Fallon) hpr0531
- 2010-08-11 HPR0562: Introduction to bash scripting (Ken Fallon) hpr0562
- 2010-11-17 HPR0598: Bash Scripting: Episode 2 Command Line Basics (Ken Fallon) hpr0598
- 2012-05-22 HPR0992: Linux In The Shell 007 - Chmod and Unix Permissions. (Dann) hpr0992
- 2012-06-05 HPR1002: Linux In The Shell 008 - free: Understanding Linux Memory Usage (Dann) hpr1002
- 2013-03-05 HPR1197: What I do with bash scripts (Jon Kulp) hpr1197
- 2013-04-09 HPR1222: LiTS 027: mathematical commands (Dann) hpr1222
- 2013-05-14 HPR1247: Recording Terrestrial Radio with bash scipts and cron jobs (Jon Kulp) hpr1247
- 2013-05-22 HPR1253: Linux in the Shell Ep 30 - vmstat (Dann) hpr1253
- Resources
- Full show notes hpr1648_full_notes.html
- Bash man page extract hpr1648_summary.pdf
- Parameter manipulation "cheat sheet" 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: