Lab 03 -- Advanced Shell scripting
This page gives an overview of the lecture and the lab session on Aug 14, 2025.
Short lecture summary
-
Programming in shell, variables and special variables, performing evaluations, repetitions (for), conditionals (while and if). Logical expressions
&&
,||
and!
. -
Use of
&
(background, foreground) and|
pipes./dev/stdin
,/dev/stdout
,/dev/stderr
for input, ouput and error streams. File descriptor and uses of redirection>
,>>
, and<
. -
Coreutils - programs
head
,tail
,shuf
,less
,sort
,uniq
,wc
,tr
,cut
,awk
,sed
,grep
,du
,stat
,find
,wget
,curl
,date
,bc
. -
Regular expressions
-
Getting help via
info
andman
pages. Also searching manpages usingapropos
and using thehelp
feature of bash.
Readings
-
The Linux Command Line by William Shotts (Online version)
Read chapters (PDF available here)
- Chapter 19 - Regular expressions
- Chapter 20 - Text processing
- Chapter 21 - Formatting output
- Chapter 30 - Troubleshooting
-
Dive Into Systems by Suzanne J. Matthews, Tia Newhall, Kevin C. Webb (Online version)
Read chapters
-
Useful commands from the GNU Coreutils and more summarised in 108 Youtube videos (each a few minutes long). If you would like a text summary, you can find it here.
-
Lectures 5, 6, 8, 9, 10, 11, 13, 14 and 15 of Unix Tools and Scripting course at Cornell.
Practise
- Read and practise the exercises from Bash academy
- Inception
- Commands and arguments
- Understanding file descriptors and redirection
- Variables and expansions
- Test and conditionals
You can also check pdf version of this document and also an older (but more complete) html version. It has lots of information on good practises and usual pitfalls to avoid in the context of writing shell scripts.
- Learn and practise regular expressions. It is a powerful tool of great help. You can practise from this website.
Additional readings
- Data wrangling - missing lectures
- Comics on systems programming by Julia Evans
- File descriptors
- Unix permissions
- Bash tips
- Pipes
- Computers are fast. How fast are they now ? You can check here.
For more comics, see here. Just search for “bash” in the search bar.