skip to content
 

Course notes

If you wish to attend this course, please ensure that you satisfy its prerequisites. (No previous experience of shell scripting is required for this course, however some knowledge of the interactive use of the Bourne-Again SHell (bash) is required; see the prerequisites for details.)

Course description

This course is part of the Scientific Computing series, and as such the examples chosen are of most relevance to scientific computing.

This course introduces shell scripting in the Bourne-Again SHell (bash) for scientific computing tasks. Day one introduces very basic shell scripts in bash which process the command line in a simple fashion. Day two covers how to write more advanced shell scripts in bash. Day three covers how to make one's shell scripts more robust.

At the end of each day of the course one or more exercises are set. It is VERY IMPORTANT that attendees attempt these exercises before the next day of the course. Attendees should make sure that they have allowed themselves sufficient study time for these exercises between each day of the course.

Upon completion of this course, attendees may find it useful to look at the course notes for the “Unix: Introduction to the Command Line Interface”  and “Further use of Unix” courses, as these notes introduce more sophisticated Unix commands that could be used in shell scripts.

Day one:

  • Recap of common Unix/Linux commands
  • What is a shell script and how does it work?
  • Errors in shell scripts
  • Writing very simple shell scripts
  • Comments in shell scripts
  • Simple use of shell builtin commands: cdechoexportpwdset
  • Simple use of shell variables and parameters
  • Simple processing of the command line
  • Redirecting standard output
  • Shell flow of control constructs: for
  • Translating your task into a shell script
  • Writing more useful shell scripts

Day two:

  • Solution to exercise from previous day
  • Structuring shell scripts
  • Testing and debugging shell scripts
  • Simple use of shell builtin commands: pwdreadtest
  • Shell flow of control constructs: while
  • Shell functions
  • Command substitution
  • The mktemp command
  • Obtaining input from the keyboard/standard input
  • Pipelines
  • Arithmetic expansion
  • Translating your task into a shell script
  • Writing more advanced shell scripts

Day three:

  • Solution to exercises from previous day
  • Handling errors in shell scripts
  • Simple use of shell builtin commands: exitreturnsettest
  • Shell flow of control constructs: if
  • Redirecting standard error
  • Handling filenames
  • Structuring shell scripts
  • Translating your task into a shell script
  • Writing more advanced shell scripts

Day four:

Day four is no-longer taught.  The course material is available for self-study, and covers:

  • Solution to exercise from previous day
  • Simple use of shell builtin commands: localsource
  • Lists of commands: ;&&||
  • Shell flow of control constructs: case
  • Handling filenames
  • More advanced use of shell variables (parameter expansion)
  • More advanced use of tests in if statements
  • More advanced processing of the command line
  • Translating your task into a shell script
  • Writing more advanced shell scripts

Notes

Printed copies of the course notes will be provided to those attending the course.  Electronic copies of the notes are also available:

Day one: Notes (PDF) Notes (ODT) Files (tar.gz) Instructions
Day two: Notes (PDF) Notes (ODT) Files (tar.gz) Instructions
Day three: Notes (PDF) Notes (ODT) Files (tar.gz) Instructions
Day four: Notes (PDF) Notes (ODT) Files (tar.gz) Instructions

The course notes featured an appendix with a list of useful Unix/Linux commands.

All comments or questions regarding this course, and any course materials provided, should be sent to .

Phone padded  Service status line: (01223 7)67999
Website  Sign up for SMS/email status alerts
Website  Read major IT incident reports

UIS bITe-size bulletin

A regular newsletter aimed at the University's IT community, highlighting service and project news from UIS.

Sign up >

Latest news

Moodle offline for upgrade during 06:00–12:00 on Tuesday 11 January

1 December 2021

Moodle, the University’s virtual learning environment, will be unavailable from 06:00 to 12:00 on Tuesday 11 January while we upgrade it to version 3.9. The upgrade will introduce several improvements and new features, including: improved forum interface with in-page replies and private reply option CRSids will be visible...

Delays in issuing University Cards and responding to queries

30 November 2021

There are likely to be severe delays in issuing University Cards and responding to queries for the next few weeks due to unexpected staff absences. We apologise for any inconvenience caused.

Update: University Wireless Service maintenance on 7 and 20 December

26 November 2021

The University Wireless Service will be undergoing maintenance between 07:30 and 08.00 on Tuesday 7 December and between 07:00 and 09:00 on Monday 20 December. These replace our previously announced times and dates, which we’ve amended to accommodate College work schedules. During these periods, users will experience...