David T-G wrote:
Per, et al --
...and then Per Jessen said... % % Anton Aylward wrote: % ... % > find . -xdev -type f -print0 | xargs -0 ls -l | \ % > awk '{size[int(log($5)/log(2))]++}\ % > END{for (i in size) printf("%10d %3d\n", 2^i, size[i])}' | \ % > sort -n % % <nitpicking> % four lines in a one-liner? % </nitpicking>
*grin*
% % You could shorten it to a three lines: % % find . -xdev -type f -ls | awk '{size[int(log($7)/log(2))]++}\ % END{for (i in size) printf("%10d %3d\n", 2^i, size[i])}' | \ % sort -n
That was a nice touch, since we're playing there. I don't use -ls much since there are so crazy many fields, and I really should try the printf options I've just learned here. But ...
The nice thing about -print0 is that it gets past ugly characters. Your version will break if you have a filename with (ew) a newline embedded, right?
I was wondering about that too, but I thought awk might be able to deal with it. -- Per Jessen, Zürich (5.4°C) http://www.hostsuisse.com/ - virtual servers, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org