Re: [SLUG] quoting

From: Eben King (eben1@tampabay.rr.com)
Date: Fri Dec 16 2005 - 19:10:32 EST


On Fri, 16 Dec 2005, Eben King wrote:

> What I want to see is this:
>
> [eben@pc eben]$ du -s /export/media/* | sort -n | cut -f 2- -d " "
> /export/media/palette.64.gif
> /export/media/palette.64.ppm
> /export/media/root.cache.980907
> /export/media/ferret-legging.txt
> /export/media/patterns
> /export/media/mod
> /export/media/midi
> /export/media/temp
> /export/media/sounds
> /export/media/backgrounds
> /export/media/movie
> /export/media/images
> /export/media/mp3
>
> Then I can pipe that sorted list through some stuff to get each element's
> size.
>
> ::tnme passes::
>
> OK, I have a winner:
>
> TAB=" "
> PP='cut -f 2- -d "$TAB"'
> ...
> du -s "$@" \
> | sort -$SORT_ARGS \
> | sed 's@ \./@ @' \
> | eval $PP ;;
>
> Jeez, what a PITA.

For the whole thing I have:

TAB=" "
PP='cut -f 2- -d "$TAB" \
| while read dirname ; do
echo "$(du -sh $dirname)"
done'
...
du -s "$@" \
| sort -$SORT_ARGS \
| sed 's@ \./@ @' \
| eval "$PP" ;;

which gives an output like

[eben@pc eben]$ time ddu -h /export/media/*
4.0K /export/media/palette.64.gif
4.0K /export/media/palette.64.ppm
4.0K /export/media/root.cache.980907
16K /export/media/ferret-legging.txt
442K /export/media/patterns
1.4M /export/media/mod
16M /export/media/midi
31M /export/media/temp
156M /export/media/sounds
413M /export/media/backgrounds
1.7G /export/media/movie
3.9G /export/media/images
5.4G /export/media/mp3

real 0m0.106s
user 0m0.010s
sys 0m0.090s

(acceptable time)

I'd like it if the "M"s, "K"s and "G"s were all aligned, but "du -sh" does
it as shown too, so I'd have to do a lot of work to make it otherwise.

Thanks Bill, for the idea.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?           [TOFU := text oben,
A: Top-posting.                                       followup unten]
Q: What is the most annoying thing on usenet?        -- Daniel Jensen

----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:56:43 EDT