Code Maven

Bash Scripting

This, along with the other courses can be given either on-site in the offices of the client or on-line via Zoom or other means. Contact Gabor Szabo for more details.



  • To be able to write and maintain scripts written in Bash


  • Experienced UNIX/Linux user
  • System administrators who would like to save time by automating tasks.
  • DevOps engineers who need to automate processes.
  • Anyone who needs to make their life on UNIX


  • In order to take this course you must have working knowledge of the UNIX shell.
  • Be able to use at least one Unix/Linux editor. Preferably Vim or Emacs.

Course format

  • Total length of the course is 16-24 academic hours. (2-3 days.)
  • About 50% of the time is hands on lab work.


Bash and Bash scripts

  • Shell types
  • Advantages of Bash
  • Executing commands
  • Shell building blocks (syntax, shell commands, shell functions)

Writing and debugging scripts

  • Hello world
  • Creating script
  • Executing script
  • Sh-bang
  • Comments
  • Debugging

The Bash environment

  • Shell initialization files
  • Configuration files
  • Variables (Global and Local)
  • Creating variables
  • Using variables
  • Exporting variables
  • Strings and Quoting characters
  • Shell expansion
  • Aliases
  • Displaying and changing Options
  • Pipelines

Wildcards are not Regexes

  • Wildcards
  • Character Classes

Regular Expressions

  • grep, egrep
  • Character classes

sed (Stream EDitor)

  • Printing lines containing a pattern
  • Deleting lines of input containing a pattern
  • Ranges of lines
  • Find and replace with sed

awk (Gawk The GNU awk programming language)

  • Getting Started with awk commands
  • Printing selected fields
  • The input field separator
  • The output field separator
  • The BEGIN and END blocks
  • User defined variables

Control Flow and Conditional statements

  • if, then, else, fi
  • Checking command line arguments
  • Testing the number of arguments
  • Testing that a file exists
  • Comparison Operators
  • Boolean operations
  • Nested if/then Condition Tests
  • exit status codes
  • case

Writing interactive scripts I/O

  • Displaying user messages using echo
  • Catching user input using the read built-in command
  • Prompting for user input
  • Redirection and file descriptors
  • File input and output
  • Here documents

Loops for Repetitive tasks

  • The for loop
  • The while loop
  • The until loop
  • Break and continue
  • Making menus with the select built-in
  • The shift built-in

Types of Variables

  • Scalars
  • Arrays
  • Constants (readonly variables)
  • Operations on variables
  • Variable assignment
  • Variable substitution


  • Function syntax
  • Positional parameters in functions
  • Listing functions

Catching signals

  • What are Signals
  • How to send signals
  • Trapping signals

Useful shell commands

  • awk
  • cat
  • cd
  • chgrp
  • chmod
  • chown
  • cp
  • cut
  • echo
  • egrep
  • exit
  • getops
  • grep
  • head
  • ls
  • mv
  • pwd
  • sed
  • sort
  • tail
  • touch
  • uniq
  • wc


If you are interested in this course, contact Gabor Szabo for more details.