Awk

Awk

Set tab as field separator

awk -F $'\t'

Output as tab separated (also as field separator)

awk -v OFS='\t'

Pass variable

a=bbo;b=obb;
awk -v a="$a" -v b="$b" "$1==a && $10=b" filename
awk '{print NR,length($0);}' filename

Find number of columns

awk '{print NF}'

Reverse column order

Check if there is a comma in a column (e.g. column $1)

Split and do for loop

Add string to the beginning of a column (e.g add "chr" to column $3)

Remove lines with string (e.g. 'bbo')

Remove last column

Usage and meaning of NR and FNR

AND gate

Round all numbers of file (e.g. 2 significant figure)

Give number/index to every row

Break combine column data into rows

Average a file (each line in file contains only one number)

Sort a row (e.g. 1 40 35 12 23 --> 1 12 23 35 40)

Subtract previous row values (add column6 which equal to column4 minus last column5)

Last updated

Was this helpful?