Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find a certain line in a file

Status
Not open for further replies.

m2001331

Technical User
May 29, 2002
73
MY
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.

 
You have to give grep a list of filenames to search in. Do you have no idea at all where this file might be? Because searching your whole system could take some time!

If you want to do that, try this as root:

[tt]find / -type f | xargs grep abc[/tt]

find will produce a list of all normal files on your system, and xargs will read the filenames and run grep abc file1 file2 file3 for a bunch of them at a time.

Note that grep is case sensitive by default! Use the -i switch to ignore case. Annihilannic.
 
Hi,

I am actually looking for a line in a file.
eg. i am looking for line "error message" .i do not know in which file this line exists.The file which contains this line can be anywhere in the system.i am trying not to go into each and every file, but instead run a command where i will be able to get the answer.

thanks.
 
Do you have any idea which programme is producing this "error message"? /var/adm/messages and /var/log/syslog would be good places to start.

What is the error message and where did you originally see it? Annihilannic.
 
hi,
my problem is this,
"error reportform" - line appears on a web page where it should not appear(this is not an error it's just a comment that appears),however it has to be traced and removed.
i do not know which source file contains this line to begin with.
i would like to know if there are any ways on how to find out which file contains this line.

thank you.
 
Are you using Apache to serve these web pages?

In that case changing my original suggestion to the following would be quicker:

[tt]find /var/apache/htdocs -type f | xargs grep abc[/tt]

Obviously change the path to the appropriate location for your web pages, or if you're using different web server software.

Is it just a plain web page or is it dynamically generated by some software?
Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top