[Top][All Lists]

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

Re: find ls sort

From: Pádraig Brady
Subject: Re: find ls sort
Date: Mon, 23 Jul 2012 18:31:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0

On 07/23/2012 06:04 PM, Eric Blake wrote:
> On 07/23/2012 09:59 AM, Enda wrote:
>> Thanks Pádraig, Eric, Andreas and Jim,
>> This almost gives the output that I want:
>> find * -mtime 0 -exec ls -rt {} +
>> Is there a way to list files not on a separate line, but one after the
>> other with a space in between them (and a newline at the end)?, like
>> '-m' except without the commas and the newline being only at end.
> Sure, except that then you are giving yourself a security hole the
> moment you find a file with a space in the name.
> find * -mtime 0 -exec ls -rt {} + | tr '\n' ' '
>> This gives the kind of output that I want except in the wrong order:
>> find -mtime 0 -printf "%f\n"
> Which has the same security hole.  Basically, any time the separator
> between file names can also occur in a file name, you are setting
> yourself up for failure, so you are better off thinking about the
> problem up front and reconsidering whether a space-separated list of
> file names is what you really want.


Also with any sorting operation, you need to deal with all the input at once.
The above `-exec ls...` could happen multiple time if you have enough files.
Therefore to be scalable you need to use something of the form: find | sort
For example see:


reply via email to

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