The UNIX and Linux Forums  

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 UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 04-16-2007
Ygor's Avatar
Ygor Ygor is offline
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,261
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 07:39 PM..
Reply With Quote