The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
String search - Command to find second occurance saurabhsinha23 UNIX for Dummies Questions & Answers 5 12-06-2007 08:03 PM
unix command/s to find files older than 2 hours in a directory Presanna Shell Programming and Scripting 6 11-20-2007 09:22 AM
Help Using Grep command to Find the string in the files in the root directory Subbu_Angeline AIX 3 01-17-2007 01:45 PM
Print lines with search string at specific position HealthyGuy Shell Programming and Scripting 4 12-04-2006 09:47 AM
Question about Restricting Search path of FIND to current directory super_duper_guy UNIX for Dummies Questions & Answers 2 10-17-2005 09:10 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-06-2007
princein princein is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 1
Unix find command to print directory and search string

Hi

i need to print pathname in which the string present using 'find' command


sample output like this


Pathname String to be searched
---------- --------------------
/usr/test/myfile get
/opt/test/somefile get



Thanks in advance
  #2 (permalink)  
Old 03-06-2007
ranj@chn ranj@chn is offline Forum Advisor  
Playing with Ubuntu Now!
  
 

Join Date: Oct 2005
Location: Chennai
Posts: 365
not clear

Did you want to list the file that had the word 'get'. Is that the string you are referring to? Se if this works for you -
Code:
find /dir/from/where/you/want/to/search -type f -exec grep -l 'get' {} \; 2>/dev/null
  #3 (permalink)  
Old 03-06-2007
dennis.jacob dennis.jacob is offline Forum Advisor  
dj -------
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 569
If you want to get the details of the file containing string 'string', you this

grep -ir 'string' /dir/from/where/you/want/to/search
  #4 (permalink)  
Old 03-06-2007
arunkumar_mca arunkumar_mca is offline
Registered User
  
 

Join Date: Oct 2004
Posts: 256
Hope u can use find with Xargs .. Will be the simple ways !!!!!!!
  #5 (permalink)  
Old 03-06-2007
andryk's Avatar
andryk andryk is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2003
Posts: 448
Quote:
Originally Posted by ranj@chn
Did you want to list the file that had the word 'get'. Is that the string you are referring to? Se if this works for you -
Code:
find /dir/from/where/you/want/to/search -type f -exec grep -l 'get' {} \; 2>/dev/null
Thanks dude, its been ages that i've searched for that kind of command!
Knowing not the minus l option of grep, I used to
Code:
find /dir/from/where/you/want/to/search -type f -exec cmd.sh 'get' {} \;
where cmd.sh is
Code:
grep $1 $2 2>/dev/null
[ $? -eq 0 ] && echo $2
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:14 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0