Question: I'm trying to list all files in `usr`, whose paths contain the key word "x86\_64-linux-gnu". For example, `/usr/bin/x86_64-linux-gnu-gcc-ranlib-5`.

First, I execute such a command:

```
find /usr -name "*x86_64-linux-gnu*" | wc -l

```

The output is 232. I can feel that it is not correct.

Then I execute another command:

```
find /usr -name "*" | grep x86_64-linux-gnu | wc -l

```

The output is 3700, which is correct.

Why doesn't the first command work as expected?

Answer: 
If you’re looking for all files whose *paths* contain `x86-64-linux-gnu`, you need to use `-path`, not `-name`:

```
find /usr -path "*x86_64-linux-gnu*" | wc -l

```

`-name` only matches against the base file name, whereas `-path` matches against the full path (as constructed by `find`, so starting with one of the initial paths given on the command line). Looking at the output of your first command will illustrate this:

```
find /usr -name "*x86_64-linux-gnu*" | less

```

You’ll see files and directories matching `x86_64-linux-gnu` themselves, such as `/usr/include/x86_64-linux-gnu`, `/usr/lib/ccache/x86_64-linux-gnu-g++`, `/usr/lib/python3.5/lib-dynload/_bz2.cpython-35m-x86_64-linux-gnu.so`, but not `/usr/include/x86_64-linux-gnu/curl` which your `grep` variant or the `-path` variant above do match.

These two expressions and their appropriate use are discussed in detail in [the `find(1)` manpage](http://man7.org/linux/man-pages/man1/find.1.html#EXPRESSION) (as always, look at `man find` on your own system first).
From `man find`:

```
   -name pattern
          Base of file name (the path with the leading directories removed) matches
          shell pattern pattern.

```

The first format (`-name "*x86_64-linux-gnu*"`) only matches files with the file's *name* matching `pattern`. If they are in a directory whose name matches the pattern, they will not be matched. However, the latter format (`-name "*"` with `grep`) does match these.