More on more (and less)

In the Linux® system, there is a fle that contains a list of dictionary words. This file is normally in /usr/share/dict/words. Each line on that file contains a single word. If you want to know how many words are in the file, try:

Alpha:~ computerlamp$  wc -l /usr/share/dict/words

Wow, isn’t that a lot of words in a single file?  The one on my system has 235,886 words.  That’s a lot.

Now imagine using more (or less) on the file and looking for a single word. This could take forever. Especially if we’re looking for vulcan because we want to make sure we spelled it right. There has to be an easier way to find this… And of course there is. If we are using more (or less) to look through the file, then we can use the . Try

Alpha:~ computerlamp$ more /usr/share/dict/words

and hit the key. Then type the word you’re looking for and it will hopefully take you to it.  Try that with turtle.  Now pretend we tried to page through the file looking for turtle.  We’d still be looking.

Now suppose we’re looking for the word way. If we type that, the command takes is to the word airway. Which is almost, but not quite, what we need. I could keep looking through the file, but that would give me every word that had way in it.  Like alway, or away or backway or cartway.  There’s an awful lot of words with way in it.

We need to tell more that we’re looking for the word that begins with way. We can do this by typing ^way (see the ^) which tells more that the word should begin with way. Now if the word isn’t found in the file, then… either you spelled it wrong (vulcan begins with a v not a w!) or it doesn’t exist in the file.  For example, google isn’t in my file!

And that’s how you find words in your files.

One thought on “More on more (and less)

  1. Pingback: Alias ... Not the Television Show - ComputerLamp

Leave a Reply

Your email address will not be published. Required fields are marked *