Operating System - HP-UX
1748216 Members
3448 Online
108759 Solutions
New Discussion юеВ

Search string in text file

 
SOLVED
Go to solution
pardeep3dec
Occasional Advisor

Search string in text file

Hi Team,
I want to search a string in all the text files specially .ksh files available into the system.
Guide me.
4 REPLIES 4
Hans_c
Occasional Advisor

Re: Search string in text file

grep "string" *.ksh

Better yet read the man page for grep.  It even includes examples

man grep

Steven Schweda
Honored Contributor

Re: Search string in text file

> I want to search a string in all the text files specially .ksh files
> available into the system.

> man grep

   Also:

      man find

   For example:

      find /usr -name '*.ksh' -exec grep <string> {} \; -print

Dennis Handly
Acclaimed Contributor
Solution

Re: Search string in text file

>       find /usr -name '*.ksh' -exec grep <string> {} \; -print

 

It's much faster to use "+" and since it does more than one file at a time, grep provides the name.

find /usr -name '*.ksh' -exec grep <string> {} +

pardeep3dec
Occasional Advisor

Re: Search string in text file

Thanks Dennis it works ....