[UFO Chicago] ls access to a dictionary?

Emad El-Haraty spork at zork.net
Sun Apr 17 13:23:04 CDT 2005


begin  Brian Sobolak  quotation:
> 
> To whit:
> 
> #ls ?ni?
> Unix?
> #ls *ni?
> unix
> linux
> 



emad at debian:~$ locate dict/words
/usr/share/dict/words

emad at debian:~$ grep -i ^.roll$ /usr/share/dict/words
droll
troll

emad at debian:~$ grep -i .izzar.$ /usr/share/dict/words
blizzard
gizzard

I think you get the idea.
here, use ^ to refer to the start words since dict/words is just a
file of words seperated by a carriage return. and $ for end of word.
since its grep, it is kind of screwy in that it will find the
substrings too, thats why i have those. in the 2nd example you don't
even need the initial . in izzard except to demand that izzar.$ is
proceeded by at least one character. what you should do to make this
more reasonable is write a simple program to make it do it without all
the carets and dollar signs. if you are anything like me, the only
time i like to see the $ is if its imprinted on a bag filled with
money.

#! /bin/bash
grep -i ^$1$ /usr/share/dict/words

So this won't follow the syntax you described in your thing, but its
pretty straight forward if you understand what grep is doing (finding
anything on that line that matches) and then how we limited the search
with ^ and $.  one thing i can see you screwing up right now is trying
to search with a leading *
i would not suggest that.

-- 
 Emad El-Haraty                                 E /
 If you can't beat them,                         M\/
 arrange to have them beaten.                     A\/
                                                   D




More information about the ufo mailing list