Manage Results Received When Searching a Database of Filenames


-n

If you use locate very much, eventually you're going to run into something like this:

$ locate pdf /etc/cups/pdftops.conf /etc/xpdf /etc/xpdf/xpdfrc-latin2 


On this computer, we get 2,373 results. Far too many! Better to use this construction instead:

$ locate pdf| less 


Pipe the output of your locate search to the pager less (which was covered in "View Text Files a Screen at a Time," in Chapter 5, "Viewing Files"), and you get your 2,373 results one manageable screen at a time.

If you just want to see the first x results, where x is an integer of your choice, use the -n option, followed by the number of results you want to see.

$ locate -n 3 pdf /etc/cups/pdftops.conf /etc/xpdf /etc/xpdf/xpdfrc-latin2 


This is far more manageable, and might be all you need. Don't let locate just spew a flood of results at you; instead, take control of the locate command's output and use it to your favor.



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