Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown   Email 



SEARCHING


Imagine you just downloaded or installed a program and you have no clue where is is gone. There are several ways to perform search.

The most easy ones are:

CODE
$ whereis gkrellm

or

CODE
$ locate gkrellm

( if gkrellm is the program you're after )

Note: for locate to work you have to create a database for fast searching :

CODE
$ su
< password >
# updatedb

Cron will keep your database up to date on a daily basis.


Special characters: * \ [....] [!....] ?

* = matches a random string of characters
\ = the “escape sign”, the character or space after this sign is ignored
? = matches 1 random character
[a-d] = matches a, b, c, d
[!a-d] = does not match a, b, c, d
[a-dA-D] = matches a, b, c, d, A, B, C, D


Now let's do some Magic:

CODE
$ ls /etc/*conf

( Will list all files in the /etc dir that end with conf including conf )

CODE
$ ls /etc/[!g-z]*

( Will list all files in /etc/ that do not start with the letters g to z )

CODE
$ locate *doc

( Will produce a long list of the files ending on doc on your computer )

Because this list is very long, and we might want to keep it:

CODE
$ locate *doc >alldocs

( Will create a textfile called alldocs in your /home listing all the doc files crowding your computer. ( Notice the speed of you lovely Linux system ) )

CODE
$ ls /mnt/win_c/My\ Documents/*txt

( Will make a list of all your txt files it finds in your C:\windows\My Documents. )
Note: Linux does not like spaces in names ! So in My\ Documents, the \ tells it to ignore the next character. An other way to do it is “My Documents”.



Another, but somewhat complicated command for searching is "find". See for instructions how to use it: The Find Command



Bruno


-- Apr 24 2003 ( Revised Dec 10 2005 ) --


Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown   Email