[Top][All Lists]

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

Re: find ls sort

From: Eric Blake
Subject: Re: find ls sort
Date: Mon, 23 Jul 2012 11:04:01 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0

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.

Eric Blake   address@hidden    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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