PDA

View Full Version : How do i find out where a certain line is


jeyagowri
03-28-03, 00:48
Hi,

I am new to Solaris and I would like find out in which file a certain line 'abc' exists.
i tried using grep but it did not return any values.
i tried to use grep from root as i am not sure in which file that particular line 'abc' exists.

thanks and regards.

sathyaram_s
03-28-03, 14:24
Can you post the command you used ...

Cheers

Sathyaram

Originally posted by jeyagowri
Hi,

I am new to Solaris and I would like find out in which file a certain line 'abc' exists.
i tried using grep but it did not return any values.
i tried to use grep from root as i am not sure in which file that particular line 'abc' exists.

thanks and regards.

g_srinivas
04-02-03, 23:40
Hi Jeyagowri,

Please try this.

find / -exec grep "search_pattern" '{}' \; -print

Rgds,

Srini.

Originally posted by jeyagowri
Hi,

I am new to Solaris and I would like find out in which file a certain line 'abc' exists.
i tried using grep but it did not return any values.
i tried to use grep from root as i am not sure in which file that particular line 'abc' exists.

thanks and regards.

g_srinivas
04-02-03, 23:43
This would take more time since it is searching from root.

Originally posted by g_srinivas
Hi Jeyagowri,

Please try this.

find / -exec grep "search_pattern" '{}' \; -print

Rgds,

Srini.

bharathanv
04-03-03, 12:07
Hi,

To find a string or a line in a set of files..you can try this command

find / -name "*.*" -print | xargs grep "<search pattern>"

This will search through all the files..if you know the type of the file..say "c" files or perl files "*.pl" you can modify the command accordingly..this will minimize the search time...

Typically, your command should look something like this...

find / -name "*.c" -print | xargs grep "abc"

Hope this helps

Regards,
Bharath (bharathanv@epatra.com)

juanep
06-24-03, 09:36
If you put /dev/null (for example) you'll get files in

find / -type f -exec grep "string" /dev/null {} \;

/J

aruneeshsalhotr
07-09-03, 20:07
You could perform the search by just using grep only.

Try the following command in the root.


grep -lRia "pattern" *

This would look for all the files for a case-insensitive pattern in all the files.

You could modify the above command by looking for only certain type of files like

grep -lRia "pattern" *.pl