Why does grep return "No such file or directory"?
I copied the following from my linux console.
grep -lr "SMTP" *.ini grep: *.ini: No such file or directory I wanted to search recursively under current location in files with extenstion .ini Actually there are files that contain "SMTP" under this directory. But I got the above error message. What is wrong? I am using centos 6. Thanks, 3rock |
You have no files matching *.ini in the current directory.
untested commands: Code:
grep -lr SMTP . Code:
find . -type f -name '*.ini' -exec grep -l SMTP {} \; |
You're not running it recurrsively, but only searching in current directory. For a recurrsive search, use "./" before *.ini, as:
Code:
grep -lr "SMTP" ./*.ini |
Try the following:
Code:
grep -lr "SMTP" --include "*.ini" |
Why does grep return "No such file or directory"?
I guess you can do either
grep -r "SMTP" * (searching under current directory and sub dir) or grep -l "SMTP" *.ini but you can't mix the two commands. That is why it failed doing what I meant to do. 3rock |
Why does grep return "No such file or directory"?
I tried this, and get the similar error
[ipbx@lab33 ~]$ grep -lr "SMTP" ./*.ini grep: ./*.ini: No such file or directory ---------- Post added 12-11-12 at 01:33 PM ---------- grep -lr "SMTP" --include "*.ini" seems taking forever. |
Alright, first make sure that is there really any file with extension .ini exists in your current directory? Once invoke:
Code:
find . -name "*.ini" -print Code:
find . -name "*.ini" -print | xarge grep -lr "SMTP" |
find command works for me.
I didn't figure out to do it using grep only without using find command. |
Although it is an old thread, I would like to add my solution to this:
grep -lr "SMTP" --include "*.ini" . regards solax |
@solax: did you read post #4 ?
|
All times are GMT -5. The time now is 05:08 AM. |