coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] ls: add --files0-from=FILE option


From: Carl Edquist
Subject: Re: [PATCH] ls: add --files0-from=FILE option
Date: Wed, 21 Apr 2021 06:28:13 -0500 (CDT)

On Tue, 20 Apr 2021, P@draigBrady.com wrote:

> One can also implement this functionality with the DSU pattern like:
>
>   nlargest=10
>   find . -printf '%s\t%p\0' |
>   sort -z -k1,1n | tail -z -n"$nlargest" | cut -z -f2 |
>   xargs -r0 ls -lUd --color=auto --
>
> Arguably that's more scalable as the sort operation will not
> be restricted by available RAM, and will use temp storage.
>
> Also it's more robust as ls is the last step in the pipeline,
> presenting the files to the user. If you wanted the largest 10
> with ls --files0-from then file names containing a newline
> would mess up further processing by tail etc.
>
>>  Similarly, say you would like to view / scroll through your extensive mp3
>>  collection in chronological order (based on when you added the files to
>>  your collection).  You can do it now with the new option:
>>
>>       [music]$ find -name \*.mp3 -print0 | ls -lrth --files0-from=-
>
> I've used a https://www.pixelbeat.org/scripts/newest script
> for a long time with similar find|xargs technique as I described above.
>
> In saying all of the above, I do agree though that for consistency
> commands that need to process all arguments with global context,
> should have a --files0-from option.
> Currently that's du and wc for total counts, and sort(1) for sorting.
> Since ls has sorting functionality, it should have this option too.


Thanks Pádraig for the thoughtful reply!

You bring up some good points, which for the sake of interesting 
discussion i'd like to follow up on also.  (Maybe later this week...)

Have a good day!

Carl

reply via email to

[Prev in Thread] Current Thread [Next in Thread]