How to search keyword in a file in Linux OS?

Asked By 30 points N/A Posted on -
qa-featured

I am not in good in Linux os, but I have keen interest about Linux, I want to search some keywords in a file that I need for my project.

Any one can help me out please?

SHARE
Answered By 0 points N/A #134395

How to search keyword in a file in Linux OS?

qa-featured

Hi Winchel,

There are very nice tools to perform your job that you desired in Red Hat Linux System.  
Grep is a command for you:

Prints lines of files where a pattern is matched

-v  do not contain the pattern
-n  lines with line number
-c  a count of lines with matching pattern
-l  name of file
-I  a case insensitive search

Please try with this that you can find your answer…

# grep jhon /etc/passwd
# ps -ax | grep “init” <file name >
# grep -A -B “fish” <file name >
# grep -c “fish” <file name>
# grep -n “fish” <filename>
# grep “t[aeiou]sh” <file name>

Britnu Salu

Related Questions