Powered By

Powered by Blogger

Selasa, 13 Oktober 2009

4 Shell Tools For Find Files In Linux

1. locate

How to use:
locate file_name

Example:
locate xorg.conf

Will return this:
/etc/X11/xorg.conf
/usr/share/man/man5/xorg.conf.5.gz
/var/lib/x11/xorg.conf.md5sum


Searching for an exacte match:
locate -r '/xorg.conf$'


Searching non-casesensitive:
locate -i 'file_Name'


Please note: locate relies on slocate database to function, which is cached. To manually update the slocate database, run:
sudo updatedb


2. which

This command tells you where a command lives.

For instance, running
which firefox

Will return:
/usr/bin/firefox


3. whereis

This command will not only tell you where the executable file is located at, but it will also locate the source, man page, and other associated directories as well.

Running:
whereis firefox

Will return something like this:
firefox: /usr/bin/firefox /usr/lib/firefox /usr/lib64/firefox /usr/share/firefox


4. find

find can basically do everything: from search for files based on last modified times, owners and groups, permissions, type (file, directory, symbolic link, etc), whether the file is readable/writable/executable by the current user, file size, whether the file or directory is empty, and much more. You can also search for matches by regular expression. Runing find with the xargs command, you can do amazing things from within a terminal.

There are many ways of using the find command so for more info, see these pages:

Example uses of the Linux Command find

Unix/Linux “find” Command Tutorial

Using the find command

Tidak ada komentar:

Posting Komentar