Afficher un message
Vieux 07/11/2006, 19h23   #4
Icarus Sparry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: files and dirs issues using 'find' piped with 'xargs ls'

On Tue, 07 Nov 2006 09:54:27 -0800, newbie wrote:

> Icarus Sparry wrote:
>> On Tue, 07 Nov 2006 09:28:31 -0800, newbie wrote:
>>

[snip]
>> >
>> > Can anyone explain to me why in (2), before 'xargs ls', there is
>> > nothing, how come 'xargs ls' takes 'nothing' as input and outputs all
>> > the dirs under the current dir?
>> >
>> > Thanks for any insights.

>>
>> It appears that your 'xargs' program runs the command at least once. Try
>> running 'xargs ls < /dev/null'.

>
> Thanks for quick reply. I just used \
> find * -type d -prune -o -type f -print | xargs ls < /dev/null
> but this still listed all dirs in the current dir that had dirs only.
>
>> And of course if you run just 'ls' it lists the things in the current
>> directory.

>
> Yes. I understand this. What I was confused, why the current dir that
> has dirs only is different from that has files and dirs mixed when I
> issue the above command. The current dir that has dirs and files mixed
> behaves "correctly", but the current dir that has dirs only (no files)
> behaves "incorrectly".


Sorry you misunderstood me. I suggested that you tried running just the
following 4 word command

xargs ls < /dev/null

to gain insight into what was happening, not to append the '< /dev/null'
to your command.

Essentially if the "find" produces no output then the "xargs" fires off
"ls". If say the find produces "fred" and "joe" as output then the xargs
fires off "ls fred joe".

You can reasonably assert that this is a bug in your copy of xargs.

Is this any clearer?
Icarus
  Réponse avec citation
 
Page generated in 0,06603 seconds with 9 queries