Re: [SLUG] quoting

From: Eben King (eben1@tampabay.rr.com)
Date: Fri Dec 16 2005 - 23:25:22 EST


On Fri, 16 Dec 2005, Eben King wrote:

> On Fri, 16 Dec 2005, Kwan Lowe wrote:
>
> > ls -1QFd /tmp/* /etc/*|grep /$ |xargs du -sk|sort -n|cut -f2 |xargs du -sh
> >
> > The above will do a listing in /tmp and etc, one line per entry, quoted,
> > with folders marked with a "/" at the end. This is passed to grep, and
> > filtered for folders. Then it just does the same two-pass sort.
> >
> > You can automate it in various ways, but the general idea is to pass a
> > pre-sorted list to du with a single directory entry at a time.
> >
> > Actually, it could be done in awk (at least a portion). Use awk to sort,
> > convert K to M if necessary, then output.
>
> OK, I see. Thanks. I took out the grep, as I want to see things besides
> directories. Then your pipeline is: ls | other stuff | xargs du. Mine is
> du | other stuff | while read. I wonder which is faster, "ls -Q" and
> "xargs" or a "while read" loop. (With "while read", I don't have to worry
> about _one_ space. It's only longer runs that get squished into one. That
> and single quotes (I think).) I'd guess that ' outnumbers " in filenames...

Used some stuff from it to simplify what I had:

case $READABLE in
    machine)
        PP=cat ;;
    human)
        TAB=" "
        PP='cut -f 2- -d "$TAB" \
        | sed "s/^\(.*\)$/\"\1\"/" \
        | xargs du -sh'
esac

case $MODE in
    name) du -sb "$@" \
            | sort -$SORT_ARGS \
            | sed 's@ \./@ @' \
            | eval "$PP" ;;

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar

Hanlon's Razor: "Never attribute to malice that which can be adequately explained by stupidity." Derived from Robert Heinlein

----------------------------------------------------------------------- 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:57:07 EDT