The pattern given to -name
has to match the entire base filename. The behaviour of the -name
pattern is defined as:
The primary shall evaluate as true if the basename of the current pathname matches pattern
This means it's true when the whole of the basename matches the pattern you gave. You can think of a pattern as being basically like a shell glob: you can use *
, ?
, and [...]
patterns inside it, with the start and end of the pattern aligned with the start and end of the string.
So your command:
find ~ -name bookmarks
finds files named "bookmarks" because that is the entire filename, but:
find ~ -name bookmark
would only find files named 'bookmark', because there are no wildcard characters in the pattern.
To match files called both bookmark
and bookmarks
, you could use:
find ~ -name 'bookmark*'
So if you want to find
those files whose names contain bookmark regardless the position of bookmark in the filename
you can use use:
find ~ -name '*bookmark*'
to match files whose names have any number of characters, then bookmark
, then any number of characters.