Solved

Need Unix Command Help finding unique values.

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now