Bash is the default unix shell on Mac OS and most Linux operating systems. Many bioinformatic programs are run using the command line, so becoming familiar with Bash is important.

Start with the fo Introduction to bash.

Basic Commands

You should familiarize yourself with the following commands.

  • alias - create a shortcut for a command
  • awk - file manipulation; Filtering; Rearranging columns
  • cat - concatenate files
  • zcat - concatenate zipped files
  • cd - change directories
  • curl - download files
  • echo - print strings
  • export - Add a variable to the global environment so that they get passed on to child processes.
  • grep - filter by pattern
  • egrep - filter by regex
  • rm - delete files
  • sed - quick find/replace
  • sudo - run as an administrator
  • sort - sorts files
  • source - runs a file
  • ssh - connect to servers
  • which - locate files on your PATH
  • uniq - get unique lines. File must be sorted.

More Advanced

You should learn these once you have the basics down.

  • git

Good Guides

Below I link to some good guides for various bash utilities.


Rearranging columns

cat example.tsv | awk -f OFS="\t" '{ print $2, $3, $1 }'

The line above will print the second column, the third column and finally the first column.

Filtering based on criteria

Print only lines that start with a comment (#) character

cat example.tsv awk '$0 ~ "^#" { print }'



Screen can be used to run things in the background. It is extremely useful if you need to run things on quest without worry that they will be terminated if you log out or get kicked off. This is essential when running nextflow because pipelines can sometimes run for many hours and its likely you will be kicked off in that time or lose your connection.