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.

Right.

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: http://www.pixelbeat.org/scripts/newest

cheers,
Pádraig.

Reply via email to