Searching all files in a directory for a specfic word

I want to read all files within the log directory to locate the word BASH or bash and present it to my screen.

Would I simply ?

cd logs
grep -i bash
NicenchrispAsked:
Who is Participating?
 
lwadwellCommented:
you should specify the files or file pattern.  Use * for all
    grep -i bash *
0
 
Ernie BeekExpertCommented:
You could use:
grep -H -r -i bash /logs/* (or /var/logs/*, where ever the dir is.
This shows the filenames containging the word, searches also any subdirectories and ignores the upper/lower case.
And if you want to see the lines where the word is found, leave out the -H.
0
 
Ernie BeekExpertCommented:
Darn, still typing too slow ;)
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
NicenchrispAuthor Commented:
this is a good answer

grep -H -r -i bash /logs/*


If I wanted it to be placed in a file can I safley assume....

grep -H -r -i bash /logs/* > /tmp/output
0
 
NicenchrispAuthor Commented:
I have to use ksh for this also !
0
 
Ernie BeekExpertCommented:
grep -H -r -i bash /logs/* > /tmp/output
You can safely assume that :)

This should run in ksh as well I assume. Let me see if I have a ksh laying around somewhere.........
0
 
NicenchrispAuthor Commented:
The grep -H -r does not work on ksh for me ?  Doesn't like either -H or -r
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.