In article
<78709f89-3881-4ab1-8b45-d0740e89d1cf@[EMAIL PROTECTED]
>,
Atropo <lxvasquez@[EMAIL PROTECTED]
> wrote:
% I drop a quick one-liner awk to get the avg time (minutes) from a ls
% command. on AIX 5.2
%
% ls -ltr|awk 'split($8,a,":");t=t+a[2] END {print t,NR ,t/NR }'
This awk program has two actionless patterns and one END action.
split($0, a, ":")
returns the number of elements in the array a after $8 has been split.
When used as a pattern, it evaluates to "true" whenever $8 is not blank.
similarly, t = t+a[2] will evaluate to "true" whenever t or a[2] is
non-zero.
The effect of a "true" pattern which has no action is to print $0.
What you want is
ls -ltr|awk '{split($8,a,":");t=t+a[2]} END {print t,NR ,t/NR }'
the braces turn those two patterns into a single action which will
be evaluated for each input record.
--
Patrick TJ McPhee
North York Canada
ptjm@[EMAIL PROTECTED]


|