But here comes a short explanation:
printf take a pattern string and a list of value, to fill into the pattern.
So the basic form is:
printf "pattern", value, value, value;
This pattern can hold any kind of text, including newlines, if you put it between doubles.
The pattern contains a placeholder for each value in the list.
The placeholders look like %n.mt, where the % is the begin of the placeholder, n is the length, m is the decimals if you have a number and t is the type of value.
n and m are optional, t can be one of a long list of which are s,d,f some examples.
s is for strings, d is for integers and f is for floats.
The complete list and further info can be found here
Transforming your example to this gives:
printf "%18s %18s %18s\n", $ip_date_time[$i]{ip}, $ip_date_time[$i]{date}, $ip_date_time[$i]{time};
update: added link to perlfunc:sprintf
update 2:there is a tutorial in the tutorial section (where else :-): Using (s)printf()
In reply to Re: Using printf
by busunsl
in thread Using printf
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |