awk $1 round code example
Example: awk round numbers up
# Basic syntax:
awk 'BEGIN {printf "%.0f\n", $field_to_round}' input_file
# Where:
- %.0f specifies that the field_to_round will have a precision
# of 0 digits (i.e. it will be rounded to an integer).
# Example usage:
awk 'BEGIN {printf "%.0f\n", 3.6}'
--> 4
# Note, if you want to print multiple fields, you have to specify how
# each will be formatted. For example, printing three fields:
awk 'BEGIN {printf "%.1f\t%.0f\t%s\n", 2.23, 3.6, 0.2}'
--> 2.2 4 0.2