find syntax (was: LFS Version 6.2 - Chapter 7. Setting Up System Bootscripts...)

Brandon Peirce brandon_peirce at
Fri Aug 18 15:41:07 PDT 2006

Mag. Leonhard Landrock wrote:

>Why does "find / -name syslogd -exec pwd ;" not work?

You need to protect the last ; from the shell so it is passed
as an argument to find, not seen as the end of the find command
by the shell. You can choose \;  ";" or ';'

BTW, the description of the -exec action in the find(1) man page
specifically says: "Both of these constructions [ ; and {} ] might
need to be escaped (with a `\') or quoted to protect them from
expansion by the shell."

Also BTW, the " -exec pwd \; " will always print just / because
"The command is executed in the starting directory." That's taken
from the same paragraph of the man page--but only in some
versions of the man page I have on my box???
You probably want:
find / -name syslogd -exec dirname '{}' ';'

- Brandon.

More information about the lfs-support mailing list