Printf [plain] www.2cto.com output function printf: printf ([format_control_flg], arg) printf modifier-left aligned Width field step, 0 indicates 0 step size. the maximum length of the prec string, or the number of digits on the left of the decimal point ------------------------------ printf format: % c ASCII character % d integer % e floating point, scientific notation, such as: 12.3 × 10e4% f floating point: 123.45% g awk decides which floating point number to use to convert e or f % o octal number % s string % x hexadecimal -------------------------------------------------- 1. character conversion echo "65" | awk '{printf "% c \ n ", $0} 'a awk' BEGIN {printf "% c # % c \ n", 92,93, 94,95, 96,97} '\] ^ _' # a awk 'BEGIN {printf "% f \ n", 0} '2017 awk' BEGIN {printf "% f \ n ", 1.0215} '192. formatting output prints formatted data row by row: awk '{printf "%-15 s % s \ n", $1, $3}' grade.txt M. tansley 48311 J. lulu 48317 P. bunny 48 J. troll 4842 L. tansley 4712 awk 'in in {printf "Name \ t \ tS. number \ n "}{ printf" %-15 s % s \ n ", $1, $3} 'grade.txt Name S. number M. tansley 48311 J. lulu 48317 P. bunny 48 J. troll 4842 L. tansley 4712 3. pass the value awk command variable = input value awk '{if ($5 <AGE) print $0}' AGE = 10 grade.txt M. tansley 05/99 48311 Green 8 40 44 J. lulu 06/99 48317 green 9 24 26 [plain] string shielding sequence ----------------------------- \ B Return key \ f go to paper feed \ n line feed \ r return key \ r tab key \ ddd eight character \ c any other character --------------------------- awk 'in in {print "May \ tDay \ n \ nMay \ 104 \ 141 \ 171"} 'May Day May Day \ 104: d's octal ASCII Code \ 141: a's octal ASCII Code \ 171: y's octal ASCII code -- the end --