Search a Database of Filenames Without Worrying About Case


locate -i

In the previous section, you tested locate by searching for any files or directories with the word haggard in the name, so you could find your collection of public domain H. Rider Haggard novels. The results looked like this:

$ locate haggard .../txt/rider_haggard .../txt/rider_haggard/Queen_of_the_Dawn.txt .../txt/rider_haggard/Allan_and_the_Ice-Gods.txt .../txt/rider_haggard/Heu-Heu_or_The_Monster.txt 


This worked because the directory containing the novels had the word haggard in it. But if that directory had instead been named H_Rider_Haggard, the search would have failed due to Linux's case sensitivity (discussed in Chapter 1, "Things to Know About Your Command Line"). Sure enough, when you use the -i option, a case-insensitive search is performed, finding files with both haggard and Haggard (and, in fact, HAGGARD, HaGgArD, and so on) in the path.

$ locate -i haggard /txt/rider_haggard /txt/rider_haggard/Queen_of_the_Dawn.txt /txt/rider_haggard/Allan_and_the_Ice-Gods.txt /txt/rider_haggard/Heu-Heu_or_The_Monster.txt /txt/Rider_Haggard /txt/Rider_Haggard/King_Solomons_Mines.txt /txt/Rider_Haggard/Allan_Quatermain.txt 


It turns out that there were more Haggard novels available than it first seemed. Remember to use -i when you want to maximize your locate results, as you can otherwise miss important files and folders that you wanted to find.

Note

For more on H. Rider Haggard, see http://en.wikipedia.org/wiki/Rider_Haggard. He's a fun, if dated, read.




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net