Bash

Below I list command-line commands you should learn. Below that I offer a little more detail.

Basic Commands

Most of these can be learned in less than an 20 minutes.

  • 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.

awk

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 }'

bcftools

Screen

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.

uniq

Get a count of lines in a file.

cat myfile.tsv | sort | uniq -c