Solved

Need Unix Command Help finding unique values.

Posted on 2007-04-10
4
443 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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…

776 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