On Fri, Oct 18, 2013 at 07:53:17AM -0500, Strake wrote: > On 18/10/2013, sin <s...@2f30.org> wrote: > > find: Useless, just do `du -a | grep blabla' > > Yes, this is what one does on Plan 9.
Which doesn't necessarily make it right. > > I realize when xargs is useful, I just hate it. > > Yep, the basic function is sane, but the other crap, insert mode and > quotation and such, loses. So just don't implement the insane bits! Does anybody here use anything but ‘-d’ or ‘-0’ and/or ‘-L’? > On 18/10/2013, Truls Becken <truls.bec...@gmail.com> wrote: > > I'm not interested in disk usage, but finding files based on certain > > properties, such as update time, ownership, permissions, etc. > > du -a | cut -f 2 No. ‘du -0 | cut -f 2-’, at least. And what the heck? That has nothing to do with what *you* just quoted above. We're talking about checking *update time*, *ownership*, *permissions*, etc., not the file name. This means I have to wrap in shell, and before I know it, my little traversal of a few million files (not kidding, real use case, though it's noticeable for smaller numbers) takes longer, not to mention that it's more code. du -a \ | cut -f 2- \ | while read -rd f; do if (($(stat --format=%a "$f") & 0111)) && [ $(stat --format=%u "$f") = $(id -u) ] && [ "$f" -nt $reference ] && [ -f "$f" ]; then chmod a-x "$f" fi done Still have to figure out how to make it work with ‘du -a0’, without using the following. awk 'BEGIN { RS="\0" } { sub("^[0-9]+[[:space:]]*", "", $0); print $0 }' I've heard that the above is non-portable due to the use of nul as the record separator. Should we care? It neither works with nawk or Plan 9 awk. You can cut a line or two if in the previous while loop if you make it slightly less readable but the point still stands, whereas… find -print0 -perm /111 -uid $(id -u) -type f -cnewer $reference | xargs -0 rm is short and sweet. Please don't implement ‘-delete’. It's both redundant and not in POSIX. Are there any other considerations that would make us want it? du's output is standardized (http://pubs.opengroup.org/onlinepubs/009604499/utilities/du.html#tag_04_40_10), mercifully, though that doesn't mean it makes handling a few special cases easy. Should we care about any such? The only ones that I can think of right now are newlines in the file names, which is pretty stupid but possible. Using du is brittle but you can use it without fear the overwhelming majority of the time. Still, if you advocate strong typing as a Haskell programmer, why wouldn't you in shell (well, not shell itself) as appropriate? Regards, Alex Pilon
pgp5MUvRUFwZl.pgp
Description: PGP signature