[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] more /usr/share/dict/words?



And Lo! The Great Prophet " Tom Knight" uttered these words of wisdom...
>
> I've been messing about writing some word and crossword games using
> /usr/share/dict/words as a dictionary. A `grep -c . /usr/share/dict/words`
> shows there are 45425 words in the file, but my paper dictionary has some
> 300000 words in it. Is there a bigger words file available anywhere?

Handy Household Hints, #4523

Instead of 'grep -c . <file>', use 'wc -l <file>' to obtain a line count. As
grep has he overhead of looking for a regular expression, it's slightly more
expensive to run compared to wc, which is just there to count lines, words
and characters.

Of course, if you've got more than '.' as the regular expression, grep makes
sense :)

The difference though is neglible (even if it is noticable) for small files,
but for large files there can be an impact. However given the two above, I'd
use wc ... if nothing else it looks neater in shell scripts :)

Chris...

-- 
\ Chris Johnson                 \
 \ cej [at] nightwolf.org.uk          \
  \ http://cej.nightwolf.org.uk/  ~-----------------------------------+
   \ Redclaw chat - http://redclaw.org.uk - telnet redclaw.org.uk 2000 \____

___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.