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" filenamePrint line number and number of characters on each line
awk '{print NR,length($0);}' filenameFind 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
Print all lines before nth occurrence of a string (e.g stop print lines when 'bbo' appears 7 times)
Print filename and last line of all files in directory
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)
Print field start with string (e.g Linux)
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?