Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Need Unix Command Help finding unique values.

Posted on 2007-04-10
4
444 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: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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