Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
google site



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 !!

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-28-2009
Registered User
 

Join Date: Dec 2009
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
How to list content with file name ?

I want to search the string including the symbol like
'search'

for example, file a.txt in \\dir contains,
a for 'appable'
b for 'banana'
c for 'cat'
s for 'search'

Here I need to display(serach outpur) like
\\dir\a.txt s for 'search'
...
...

How to list content with file name for current + sub directories ?

I tried below commands for the above serach


Code:
find . -exec grep -i "'search'" {} \; - listing content only
find . -exec grep -l "'search'" {} \; - listing file name only
find . -exec grep -il "'search'" {} \; - listing file name only
grep "'search'" * - looking current directory

I need to display content with file name

help me

Thanks!

Last edited by gkskumar; 12-28-2009 at 05:21 AM.. Reason: removed links, added code tags
Sponsored Links
  #2  
Old 12-28-2009
root cause analyst
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 1,771
Thanks: 5
Thanked 78 Times in 75 Posts
How about:

Code:
grep -r "'search'" "$(pwd)"/*


Last edited by Scrutinizer; 12-28-2009 at 06:35 AM..
  #3  
Old 12-28-2009
Registered User
 

Join Date: Jul 2009
Location: Noida - India
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Hi

how about :-

Code:
find . -print | xargs grep -i "search"

cheers
  #4  
Old 12-28-2009
Registered User
 

Join Date: Dec 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
find . -exec grep "'search'" { } \; -print
  #5  
Old 12-28-2009
root cause analyst
 

Join Date: Nov 2008
Location: Amsterdam
Posts: 1,771
Thanks: 5
Thanked 78 Times in 75 Posts

Code:
find . -exec grep -H "'search'" {} \;

  #6  
Old 02-23-2010
kiruthika_sri's Avatar
Registered User
 

Join Date: Feb 2010
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
grep -RH "'search'" *
Sponsored Links
Reply

Bookmarks

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


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Extract specific data content from a long list of data patrick87 Shell Programming and Scripting 11 12-14-2009 01:07 AM
Shell script or command help to extract specific contents from a long list of content patrick87 Shell Programming and Scripting 2 10-07-2009 09:11 PM
list file content as individual variables petersf Shell Programming and Scripting 4 10-06-2009 11:55 AM
Need help with awk - how to read a content of a file from every file from file list tanit Shell Programming and Scripting 7 03-10-2009 04:19 AM
find for specific content in file in the directory and list only file names madhu_Jagarapu AIX 2 12-23-2008 01:13 AM



All times are GMT -4. The time now is 07:59 AM.