Basic use
Example:
print requred fields
awk -F "/t" '$2>30{print $3"/t"$4}' a.txt > b.txt
This sentence means the seperator in a.txt is "/t" and print the third and forth fields when the second filed is greater than 30.
Use BEGIN and END
format:awk -F "/t" 'BEGIN{ initial variables} { if (condition) { compute body} } END{ output instruction}.
Example
print the sum of specified fields.
awk -F "/t" 'BEGIN{sum = 0} {if ($3/$4>0.5 && $4>40) { sum += $4} }END{print sum}' a.txt
Above sentence print the sum of the forth fields when the third and forth fields meet the condition ($3/$4>0.5 && $4>40)