shell programming

" There are dark corners in the Bourne shell, and people use all of them. "
Chet Ramey

what not to do

  • Do not name your script ‘test’ because ‘test’ is a shell builtin. Naming your script ‘test’ will lead to some less amusing side effects.

shell programming

intro

created onApril 18, 2022
Shell programming can be used to write shell scripts that simplify tasks that can be done on the command line....

shell programming

output

created onApril 18, 2022
For output, two commands can be used: echo and printf. Both commands are available as a shell built-in and/or...

shell programming

terminal input

created onApril 18, 2022
User input from the terminal can be processed with the command read By default read reads user input from...

shell programming

variables

created onApril 18, 2022
variable names Variable names are case sensitive. They have to start with a lower or an upper case letter or an underscore....

shell programming

options parsing

created onJanuary 18, 2022
There are several methods for the parsing options / parameters supplied to the shell script ....

shell programming

arrays

created onJanuary 18, 2022
welcome to the world of negative indices and other barnyard oddities....

shell programming

2nd order reference

created onJanuary 18, 2022
A 2nd order reference is a reference that references the variable with the name which is the value...

shell programming

functions

created onJanuary 18, 2022
how to work with functions – or what is sold to you as functions in shell programming...

shell programming

conditionals

created onJanuary 18, 2022
general form of test expressions, i.e. for loops and if statements...

shell programming

loops

created onJanuary 18, 2022
In Bash shell programming you can use the usual suspects for loop structures: the for loop, which is usually used to...

shell programming

trapping signals

created onJanuary 18, 2022
how to trap signals that are sent to your shell script and how to handle them properly...

shell programming

screen and cursor control

created onJanuary 19, 2022
controlling cursor position, text attributes and screen display with tput...

shell programming

reading files

created onJanuary 18, 2022
working with file descriptors and reading files in a shell script with the read command...

shell programming

locking

created onJanuary 18, 2022
locking with homegrown solutions and the command dotlockfile...

shell programming

deprecated syntax

created onJanuary 18, 2022
Expressions like <expr> are still prevalent in the wild. If you work with shell script code that uses this deprecated code...

shell programming

testing

created onJanuary 18, 2022
shellcheck Check shell scripts with ‘shellcheck’ print out executed expression Test shell scripts with the ‘-x’ switch:...