Finding Data with Other Unix Commands


In the previous section of this lesson we learned about the find command. When used, it can be powerful. Other commands you can use are whereis and which, and these commands may bring you results as well.

The whereis Command

The whereis command can be used to run a quick search on a specific number of directories for whatever you specify. For example, if you wanted to run a search on a file named "test", then you would get all instances of "test" that came up within that preset number of directories, such as paths to source code, binaries, and man pages. The whereis command performs a quick search for the file you specify.

 >whereis test test: /usr/bin/test /usr/share/man/man1/test.1.gz /usr/share/man/man1p/test.1p.gz 

Although this may not be exactly what you are looking for, this command can be useful.

The which Command

Another useful command is the which command. The which command can help you find files that are specified in your PATH environment variable. This was covered earlier in the book and will also be covered in Lesson 16, "Modifying Your Environment." This means that unless your data is specified in a location (such as a directory) within that PATH statement, you will not find it with use of the which command.

The which command is not useful in this scenario, but that does not mean that it can't be helpful. You may need to edit a file that you absolutely know is in your PATH statement and use this command to recall it quickly.



    SAMS Teach Yourself Unix in 10 Minutes
    Sams Teach Yourself Unix in 10 Minutes (2nd Edition)
    ISBN: 0672327643
    EAN: 2147483647
    Year: 2005
    Pages: 170

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