Table of Contents

A non-comprehensive list of bash commands

I have listed a number of common bash commands that come in handy when working in a shell.
You can try the following basic commands on the example file to understand what they are doing.

Feel free to complement your notes on the compilation of basic commands.

Slightly more advanced bash

AWK

This command is also considered a programming language on its own. It is particularly useful when you need to process the elements of a table. The basic syntax is as follows:

awk -F "\t" '{print $2 "\t" $1} file.txt
awk -F "\t" '$3 > 10 {print $0}'

Sort

sort -g -u file.txt

Translate

tr '[ATGC]' '[TACG]' | rev

sed (slightly more advanced)

sed -n -e '/AAA/,/BBB/ p' file.txt

Working with lists and tables

Play with the following sample files.comm_join_example.tar.gz

comm

To compare contents of both files (in this case, the identifiers of the first column of the two files):

comm <() <()
comm <(cut -f1 1_table.txt | sort) <(cut -f1 2_table.txt | sort) | sed -e 's/$/\t\t/' | cut -f1,2,3

join

Join two tables based on a column in common.

join -t $'\t' <() <()
join -t $'\t' -a1 <(sort -k1,1 1_table.txt) <(sort -k1,1 2_table.txt)