Command comparisons

Hi guys,
Im trying to figure out what is the difference between using a | and the command xargs ... examples of usage:

1) ls * | wc -w => this gives you the number of files in the current directory including all subdirectories

2) find . �*.log� | xargs grep ERROR => this gives you all the occurrences of ERROR in all .log files in the current directory and all subdirectories

PLUS! what is the difference of the above commands to this one below and why should I use one instead of the other:

find . �*.log� -exec grep ERROR �{}' \;

Any help will be very much appreciated.

why dont you read manual page ?

man xargs

Avoid "Urgent help needed" in the Thread, otherwise it will be closed by admin.

I did read the man page for xargs but i don't have the basis to compare it with |.
im sorry bout the thread title, i didn't know it wasn't allowed im a real newbie here.

The below page gives answers for all your qeustion

Unix Xargs

Being new is no excuse. You have to accept the rules when you register. Accepting without reading them is your own fault and does not exempt you from following them.

There are some funny quote characters here like it has come from a Windows editor. Also the "-name" parameter is missing.

You probably mean:

find . -type f -name '*.log' | xargs grep "ERROR"
find . -type f -name '*.log' -exec grep "ERROR" {} \;

On many modern versions of "find" the "+" syntax is actually fastest of all:

find . -type f -name '*.log' -exec grep "ERROR" \+

Addendum:

Sort of true. It does however exclude filenames starting with a period (e.g. .profile). It also sorts each directory to alphabetical order which is a bit of a waste if all you wanted to do was count them. It also gives an incorrect count if any filename contains a space character because you are counting "words". You also count directory files but because "including all subdirectories" is ambiguous it's hard to tell whether this is intentional.

This is a more efficient and accurate way to count every type of file (including directory files)
find . -print |wc -l
Or if your "find" allows the syntax:
find . | wc -l

Or if you just want to count all files:
find . -type f | wc -l

Thanks guys to all the reply. Really appreciate it. again my apologies.