The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
read list of filenames from text file and remove these files in multiple directories fxvisions Shell Programming and Scripting 5 08-07-2008 04:59 PM
Removing certain text from multiple filenames Djaunl UNIX for Dummies Questions & Answers 6 01-15-2008 05:52 PM
Appending text to a number of similar filenames Djaunl UNIX for Dummies Questions & Answers 4 10-10-2007 12:16 AM
read list of filenames from text file, archive, and remove fxvisions Shell Programming and Scripting 5 03-20-2007 09:56 PM
searching for filenames with search strings in another file pathanjalireddy Shell Programming and Scripting 3 06-08-2005 06:35 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 01-16-2008
skyineyes skyineyes is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 150
Searching filenames containing certain text???

Suppose there are multiple files containing certain text "abc". How to print the name of all such files with a single command from unix prompt?

Thanks in advance
  #2 (permalink)  
Old 01-16-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926

Code:
grep -l abc *

  #3 (permalink)  
Old 01-16-2008
skyineyes skyineyes is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 150
will this serve the purpose?
i expected if to use find, xargs and print combination ..... what say????

Quote:
Originally Posted by radoulov View Post
Code:
grep -l abc *
  #4 (permalink)  
Old 01-16-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,926
If want it recursive (with GNU grep):


Code:
grep -Rl abc *

  #5 (permalink)  
Old 01-16-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,641
Quote:
Originally Posted by radoulov View Post
If want it recursive (with GNU grep):


Code:
grep -Rl abc *
The same is true for the AIX grep: "-R" is "recursive without following links", "-r" is "recursive including following links". This can be fine tuned by using the "-H" and the "-L" option together with -r/-R.

bakunin
  #6 (permalink)  
Old 01-16-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,557

Code:
find /full/path -type f -exec grep -l "abc" "{}" \;

  #7 (permalink)  
Old 01-16-2008
ilan ilan is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 101
you can go to the folder and run the below one-liner which list out the files

grep -s "abc" * | cut -d : -f1 | uniq

-ilan

PS:editing my post; as it is a late commit
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:28 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