Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fuzzy?

Status
Not open for further replies.

mrn

MIS
Apr 27, 2001
3,993
GB
Anyone got any ideas on how to do a fuzzy type search on a string in ksh, without cutting the string up (too many naming variations)

my script works when lsvg output like

VOL_PROD_NO1_vg

and vcs command produces

VOL_PROD_NO1

but when

lsvg produces something like

VOL_PROD_NO1_vg

vcs command produces

VOL_LIVE_NO1

the script fails.

Ideally need just to match the majority of the string.

Ideally I'd go round and fix the mismatches (which I may end up having to do) but just wondered if anyone has any fancy tricks.



Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
my script works
Which script ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Not really important about the script, was just trying to explain the concept of what I'm after. Which is ideas for fuzzy search, bit like what agrep offers, but without the agrep.

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Something like;

VG="AAA_BBB_CCC"
VCS="AAA_XXX_CCC"

VG_A=`echo $VG|cut -f 1 -d _`
VG_B=`echo $VG|cut -f 2 -d _`
VG_C=`echo $VG|cut -f 3 -d _`
VCS_A=`echo $VCS|cut -f 1 -d _`
VCS_B=`echo $VCS|cut -f 2 -d _`
VCS_B=`echo $VCS|cut -f 3 -d _`


if [ $VG_A = $VCS_A -a $VG_A = $VCS_A];then
NAME=`grep "$VG_A*VG_B" filename`
SERVICE_GROUP=`hares -value $NAME Group`
else
......
done

But VG may be "AAABBBCCC" or "AAA_BBBCCC" or "AAABBB_CCC" or "AAA_BBB_CCC_DDD" or "aaabbbccc" or Etc.....

Might have to dig the Perl book out......

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Ooooooo don't you hate inconsistent naming unconventions!!

Without seeing more of your data and examples of what you consider matches and mismatches it's hard to say. I'd start by stripping out underscores and converting to lower case, and then probably by stripping out "common" components like "live", "prod", "vg", "vol", etc... but that could easily result in unwanted matches.

Annihilannic
[small]tgmlify - code syntax highlighting for your tek-tips posts[/small]
 
Guess I'll go and fix the names then......

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top