Link to home
Start Free TrialLog in
Avatar of tmonteit
tmonteitFlag for Afghanistan

asked on

Need Unix Command Help finding unique values.

I need to redo my style sheets for 150 jsp files
 
I want to find all the unique classes among my jsp files.  


find . -name "*.jsp" -print |  xargs grep "class="  | wc -l
    produces 4000+ results

My guess is that there are only about 200 unique terms in the quotes after class="className".

For example if this was my results, there are only 3 unique classes.
   <td class="columnValue">
   <td class="myOtherClass">
   <td class="aThirdClass">
      <td class="aThirdClass">

How do I build a unix command to only show me the unique class="className"  where className is unique?

Avatar of ozo
ozo
Flag of United States of America image

perl -MFile::Find -le '$/="class=";find(sub{return unless /\.jsp$/;@ARGV=($_);/^"(.*?)"/&&$s{$1}++while<>},"."); print for sort keys %s'
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tintin
Tintin

Thanks ozo.  I forgot the .* at the beginning