problem using pipes with "ls"

Hi all,

I tried the following command

$ find / -name xyx | ls -l

so logically it should show the listing of directory xyz , assuming there's only one instance of xyz . But the above command shows the listing of current directory instead.

I got the desired result using it in the following maner

$ find / -name xyx | xargs ls -l

so, the confusion is why do I need xargs here

Hi!
That is because ls does not operate on standard input - you have to feed it standard input as an argument - that's why you use xargs.

if you want use xargs

find / -name XYZ -type f | xargs -iINCLUDE ls -l INCLUDE

or

find / -name XYZ -type f -exec ls -l {} \;
find . -ls

1} So Many bways to to the same thing
2) In UNIX very often, the simplest way is already programmed