grep not working

Erro with unix query

grep -C20 'contactNumber before is------>'  *

above grep command gives below error message
grep: diagnostic_images: Is a directory
grep: jmsservers: Is a directory

what it means?

please advise
LVL 7
gudii9Asked:
Who is Participating?
 
Kent WSr. Network / Systems AdminCommented:
That's not an error. You give "*" at the end of your command, which means "search through all files in the local directory".  If grep encounters directories that are not files, it's just telling you it can't grep a directory.
0
 
nociSoftware EngineerCommented:
So none of the files matched, but there are subdirectories...,
either exclude the directories (ie. replace * by something more appropriate)  or if you want to include the subdirectories, then use -r as an extra option before or immediate after -C20
0
 
gudii9Author Commented:
if i want to search on log files only  like
file1.log009
file2.log008
etc
can i use below command?
grep 'contactNumber before is------>' *.log*
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Seth SimmonsSr. Systems AdministratorCommented:
can i use below command?

yes since you are specifying a certain file name pattern
however, since you used the wildcard before and had nothing, as mentioned, use -r to be recursive through subdirctories
else, as-is, that command will return nothing if there are no *.log* files in that current folder
0
 
nociSoftware EngineerCommented:
yes the would be the right command.
0
 
Prabhin MPEngineer-TechOPSCommented:
Hi,
Please use -R parameter while grep , this may help  you to solve.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.