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




Thread: Grep with count
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 04-16-2007
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,409
This will count files with the same extension...
Code:
find . -type f -print|awk '{print match($0,/\.[^/]*$/)?substr($0,RSTART,RLENGTH):"No Ext"}'|sort|uniq -c
...which gives...
Code:
     12 .env
      7 .gif
      2 .htm
     26 .html
      8 .inf
      2 .ini

Last edited by Ygor; 04-16-2007 at 11:39 PM..