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

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 04-07-2006
Registered User
 

Join Date: Mar 2006
Posts: 25
help on awk

In a file directory, how can I only get the file-name which contains a pattern inside the file using awk?

for example, there are 3 text files in a directory,

file_1, file_2, file_3

I'd like to find the file (I need file name only, not the line contains the pattern) which the file body contains a word "testing". How can I do it using awk?

Thanks

Last edited by ting123; 04-07-2006 at 02:54 PM.
Reply With Quote
Forum Sponsor
  #2  
Old 04-07-2006
Registered User
 

Join Date: Feb 2006
Posts: 34
Try this

ls -1 | awk '/testing{1,}/'
Reply With Quote
  #3  
Old 04-07-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,269
why awk?
Code:
ls *testing*
Reply With Quote
  #4  
Old 04-07-2006
Registered User
 

Join Date: Mar 2006
Posts: 25
the purppose I want is find the file which contains a pattern in the file, not in the file name
Reply With Quote
  #5  
Old 04-07-2006
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,003
Quote:
Originally Posted by ting123
the purppose I want is find the file which contains a pattern in the file, not in the file name
grep -l testing *
Reply With Quote
  #6  
Old 04-07-2006
Registered User
 

Join Date: Mar 2006
Posts: 25
In this particular case, the line in the file is too long to over the "grep" command's limitation, so neither "grep" or "egrep" or "fgrep" won't work. That's why I need find out how to do it either "awk" or "sed"

Best
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:42 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0