Solved grep: unknown directories method

hello,

I want to use grep like this:

Code:
find ../../../Src/KERNEL_SRC_7.6.0 -iname '*' -exec grep -H '-ldl' {} \;
to find occurrences of '-ldl' in the config files of a software package. Instead of the expected search result I get the message in the title of this thread, repeated many times. In case it is relevant, I'm using FreeBSD 10.2-RELEASE amd64 and zsh.

What am I doing wrong?

Thanks for any help,
sprock
 
You need to escape the dash: '\-ldl'. Otherwise grep interprets ldl as options.

Any reason you are using find(1)? You are matching all filenames anyway, so a grep -r would do. It searches through all files and subdirectories of a directory.

Code:
grep -r '\-ldl' ../../../Src/KERNEL_SRC_7.6.0
or
Code:
find ../../../Src/KERNEL_SRC_7.6.0 -iname '*' -exec grep -H '\-ldl' {} \;
 
You need to escape the dash: '\-ldl'. Otherwise grep interprets ldl as options.

Any reason you are using find(1)? You are matching all filenames anyway, so a grep -r would do. It searches through all files and subdirectories of a directory.

Code:
grep -r '\-ldl' ../../../Src/KERNEL_SRC_7.6.0
or
Code:
find ../../../Src/KERNEL_SRC_7.6.0 -iname '*' -exec grep -H '\-ldl' {} \;

Many thanks, I was sure I had tried escaping the '-'. The real find command is more complex, I tested, and wanted to ask, with a simpler version.

sprock
 
You may want to add -type f to have it only work on files.
 
Back
Top