If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > How do i find out where a certain line is

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-27-03, 23:48
jeyagowri jeyagowri is offline
Registered User
 
Join Date: Mar 2003
Posts: 11
How do i find out where a certain line is

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.
Reply With Quote
  #2 (permalink)  
Old 03-28-03, 13:24
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,543
Re: How do i find out where a certain line is

Can you post the command you used ...

Cheers

Sathyaram

Quote:
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.
Reply With Quote
  #3 (permalink)  
Old 04-02-03, 22:40
g_srinivas g_srinivas is offline
Registered User
 
Join Date: Mar 2003
Posts: 12
Re: How do i find out where a certain line is

Hi Jeyagowri,

Please try this.

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

Rgds,

Srini.

Quote:
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.
Reply With Quote
  #4 (permalink)  
Old 04-02-03, 22:43
g_srinivas g_srinivas is offline
Registered User
 
Join Date: Mar 2003
Posts: 12
Re: How do i find out where a certain line is

This would take more time since it is searching from root.

Quote:
Originally posted by g_srinivas
Hi Jeyagowri,

Please try this.

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

Rgds,

Srini.
Reply With Quote
  #5 (permalink)  
Old 04-03-03, 11:07
bharathanv bharathanv is offline
Registered User
 
Join Date: Apr 2003
Location: Bangalore (India)
Posts: 2
Try using xargs

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)
Reply With Quote
  #6 (permalink)  
Old 06-24-03, 08:36
juanep juanep is offline
Registered User
 
Join Date: Jun 2003
Posts: 3
If you put /dev/null (for example) you'll get files in

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

/J
Reply With Quote
  #7 (permalink)  
Old 07-09-03, 19:07
aruneeshsalhotr aruneeshsalhotr is offline
Registered User
 
Join Date: Jul 2003
Location: US
Posts: 314
Talking Grep results

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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On