Advanced bash scripting 2015
Welcome to the web page for the course "advanced bash
scripting".
The lecture notes as well as a list of the material covered can be found
at the end of the page. An abstract of the of the
course can also be found further down. This course was the first
installment of my sequence of courses on UNIX script writing. The
subsequent course is the "Introduction to awk
programming" course in
August 2016.
Update: I taught the course a second time in November 2017, for which I also revised the course material.
Course structure
The course will take place from the 24th to the 28th August 2015 at Heidelberg University . We will meet in the Computer Room U012, which is in the basement of INF 350, Otto-Meyerhof-Zentrum. The course is structured as a full day course running from 9:30am till about 5pm each day (with a one hour lunch break in between).
Abstract
The bash
shell is the default shell in almost all major UNIX and LinuX
distributions, which makes learning about the bash
scripting language
pretty much unavoidable if one is working on a UNIX-like operating
system. On the other hand this also means that writing bash
scripts is
conceptually very simple — essentially like typing commands. When it
comes to more involved tasks and more powerful scripts, however, some
knowledge of the underlying operating system is certainly required.
After all bash
scripting is all about properly combining the programs
available on the UNIX operating system in a clever way.
This idea structures the whole course:
In the first part we will revisit some basic concepts of a UNIX-like
operating system and review the set of UNIX coreutils one needs for
everyday scripting. Afterwards we will talk about the bash
shell and
its core language features, including
- control statements (
if
,for
,while
, ...) - file or user input/output
bash
functions- features simplifying code reuse and script structure
The final part will be concerned with the extraction of information
(from files etc.) using so-called regular expressions and programs like
awk
, sed
or grep
.
Learning Targets
After the course you will be able to
- apply and utilise the UNIX philosophy in the context of scripting
- identify the structure of a
bash
script - enumerate the core concepts of the
bash
scripting language - structure a script in a way such that code is reusable in other scripts
- extract information from a file using regular expressions and the standard UNIX tools
- name advantages and disadvantages of tools like
awk
,sed
orgrep
,cut
..., and give examples for situations in which one is more suitable than the others.
Prerequisites
This course assumes some familiarity with a UNIX-like operating system
like GNU/Linux and the bash
shell. I.e. you should be able to
- navigate through your files from the terminal.
- create or delete files or folders from the terminal.
- run programs from the terminal (like some "one-liners").
- edit files using a common graphical (or command-line) text editor
like
gedit
,leafpad
,vim
,nano
, ...
Whilst it is not assumed that you have any knowledge of programming or
any experience in bash
scripting, it is, however, highly recommended
that at least either is the case.
Files
Link |
---|
Course abstract |
Lecture notes |
Course files (including notes, resources and example files) |
Solutions to the exercises (pdf with comments) |
Solution script files |