Changes

Printf bash builtin

2,051 bytes added, 19:49, 9 February 2014
The following lines were added (+) and removed (-):
The price is formatted to a floating point number of 9 places with 2 decimals.Breakdown of formatting arguments:* %-10s  (line 6): '''string''' the - means format form left align over 10 spaces* %8d  (line 7): '''signed decimal number''' with 8 places * %11.2f  (line 7): '''floating point number''' to 9 places with 2 decimals === escape codes ===   === format arguments === Additional arguments available to printf for formatting* %b Print the associated argument while interpreting backslash escapes in there* %q Print the associated argument shell-quoted, reusable as input* %d Print the associated argument as signed decimal number* %i Same as %d* %o Print the associated argument as unsigned octal number* %u Print the associated argument as unsigned decimal number* %x Print the associated argument as unsigned hexadecimal number with lower-case hex-digits (a-f)* %X Same as %x, but with upper-case hex-digits (A-F)* %f Interpret and print the associated argument as floating point number* %e Interpret the associated argument as double, and print it in <N>±e<N> format* %E Same as %e, but with an upper-case E in the printed format* %g Interprets the associated argument as double, but prints it like %f or %e* %G Same as %g, but print it like %E* %c Interprets the associated argument as char: only the first character of a given argument is printed* %s Interprets the associated argument literally as string* %n Assigns the number of characters printed so far to the variable named in the corresponding argument. Can't specify an array index. If the given name is already an array, the value is assigned to the zeroth element.* %a Interprets the associated argument as double, and prints it in the form of a C99 hexadecimal floating-point literal.* %A Same as %a, but print it like %E* %(FORMAT)T output the date-time string resulting from using FORMAT as a format string for strftime(3). The associated argument is the number of seconds since Epoch, or -1 (current time) or -2 (shell startup time). If no corresponding argument is supplies, the current time is used as default === modifiers === {{:sparse entry}} [[Category:Computer_Technology]][[Category:Linux]]
Bureaucrat, administrator
16,192
edits