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
Can I make "touch" create executable files by manipulating umask? tphyahoo Shell Programming and Scripting 2 01-30-2009 04:20 PM
"find command" to find the files in the current directories but not in the "subdir" swamymns Shell Programming and Scripting 9 07-22-2008 11:23 AM
diff on c-source file always returns "files differ" C-Prog-Man UNIX for Dummies Questions & Answers 7 08-31-2006 01:57 PM
Perl CGI to access / edit "root" owned config files WIntellect Shell Programming and Scripting 1 04-23-2003 03:48 PM
File names that contain "01" act hidden n9ninchd UNIX for Dummies Questions & Answers 8 06-09-2001 10:25 AM

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

Join Date: Aug 2007
Posts: 12
total number of files which have "aaa" in files whose names are File*_bbb*

I am getting the list of all the files which have "aaa" from files whose name is File*_bbb*.

grep -l "aaa" File*_bbb*

But I want to count the number of files. That is I want the total number of files which have "aaa" in
files File*_bbb*

If I run the following for getting number of files, I am getting 0 files returned.
grep "aaa" File*_bbb* | wc -l


So how do I get the total number of files which have "aaa" in files whose names are File*_bbb*
  #2 (permalink)  
Old 08-16-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Try this:

Code:
grep -l "aaa" File*_bbb* | wc -l


If your last command
Code:
grep "aaa" File*_bbb* | wc -l
returns 0, it means that there are no occurrences of the pattern "aaa" in all the searched files (File*_bbb*). In any case, the result of this command is not what you want, because if in a file the pattern is matched more than once, you will have the count of ALL the occurrences and not the count of the files which contains the pattern.
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:39 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