The UNIX and Linux Forums  

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
find , grep james94538 UNIX for Dummies Questions & Answers 3 10-09-2008 10:03 PM
Combination of find -xargs & wc -l mr_bold UNIX for Dummies Questions & Answers 4 07-08-2008 06:07 AM
grep, find or awk? netrom UNIX for Dummies Questions & Answers 4 04-09-2008 06:03 PM
'find' and 'tar' combination kharen11 Shell Programming and Scripting 2 02-06-2008 08:17 AM
find and grep sarwan High Level Programming 4 04-10-2006 08:05 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 09-23-2008
nervous nervous is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 55
Grep and find combination

Hello All,

I'm trying the following:
Code:
find . -name "*" -exec grep -ln "IsAlpha" {} \;
It gives me file names only (having string "IsAlpha"), I want to get line numbers also, something like this: test 1: Line 52
test 1: Line 95 etc

Is it possible to obtain using grep & find only.
  #2 (permalink)  
Old 09-23-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,771
grep -l turns off all the other output from grep. All you see is filename, and only if the string is found.
  #3 (permalink)  
Old 09-25-2008
nervous nervous is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 55
Please suggest me if there is any alternative to achieve the above and also please advise if my way of using "find" is correct or there is anything I need to change?
  #4 (permalink)  
Old 09-25-2008
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,400
try something like this..
Quote:
find . -name "*" -exec awk '/IsAlpha/{print NR,FILENAME}' {} \;
  #5 (permalink)  
Old 10-06-2008
nervous nervous is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 55
I tried the following:
Code:
find . -name "*" -exec awk '/IsAlpha/{print NR,FILENAME}' {} \;
But it takes very long time to finish, please note that I have to search in directory /data/Programs, but I think this command continues searching in whole /data directory, any suggestions to improve this search? Thanks in advance.
  #6 (permalink)  
Old 10-08-2008
ajayreddy ajayreddy is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 2
find . -name "*" -exec grep -Hn "IsAlpha" {} \;
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 09:30 AM.


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