Solved

Need Unix Command Help finding unique values.

Posted on 2007-04-10
4
446 Views
Last Modified: 2013-12-26
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?

0
Comment
Question by:tmonteit
  • 2
  • 2
4 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 18887426
perl -MFile::Find -le '$/="class=";find(sub{return unless /\.jsp$/;@ARGV=($_);/^"(.*?)"/&&$s{$1}++while<>},"."); print for sort keys %s'
0
 
LVL 48

Accepted Solution

by:
Tintin earned 350 total points
ID: 18887541
find . -name "*.jsp" -print |  xargs grep "class=" | sed 's/<td class="\(.*\)">/\1/' | sort -u


0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 150 total points
ID: 18887631
It may be beter to use
sed 's/.*<td class="\(.*\)">.*/\1/'
assuming there's no more than one <td class= per lie
0
 
LVL 48

Expert Comment

by:Tintin
ID: 18888037
Thanks ozo.  I forgot the .* at the beginning
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
zeroFront challenge 7 121
canBalance challenge 34 104
Linux Ubuntu - Gave up waiting for root device. ALERT! /dev/sda1 does not exist 16 242
Problem to Office 1 40
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question