linux下查找文件命令:locate 和 find
2011-10-25 17:00
567 查看
如下内容来自:http://hi.baidu.com/hunnon/blog/item/20f6a627e2b4481d8a82a1d7.html
对于初次切换到 Linux 系统的朋友来说,如果想要从命令行界面执行查找文件的任务的话,那么,locate 和 find 是两个需要了解的命令。虽说这两个命令都可以满足查找文件的操作,不过却是各有所长,在选择上不妨兼而用之。
locate:该命令在运行时需要后台索引的数据库作为支撑,在 Ubuntu 中这个数据库文件位于 /var/cache/locate/locatedb。一般来说,这个数据库文件每天是通过 cron 自动更新的。如果不幸没有得到更新,那么可以执行
find:这是另一个 Linux 系统中重要的文件查找命令。find 命令的功能很强大,其一般使用方法为:
值得注意的是,对于 locate 与 find 这两个命令的解说远非这篇小文所能满足。关于这两个命令的更加详细的用法,你可能需要通过 man locate 或 man find 查询。
对于初次切换到 Linux 系统的朋友来说,如果想要从命令行界面执行查找文件的任务的话,那么,locate 和 find 是两个需要了解的命令。虽说这两个命令都可以满足查找文件的操作,不过却是各有所长,在选择上不妨兼而用之。
locate:该命令在运行时需要后台索引的数据库作为支撑,在 Ubuntu 中这个数据库文件位于 /var/cache/locate/locatedb。一般来说,这个数据库文件每天是通过 cron 自动更新的。如果不幸没有得到更新,那么可以执行
sudo updatedb来手动更新。 假如我想要在系统中查找一个名为 linux.html 的文件,那么可以这样执行命令:
locate linux.html。locate 搜索文件的速度很快,一会儿就会把结果列出来。locate 有一个十分有用的选项 -r,它可以让你在搜索文件时使用正则表达式。
find:这是另一个 Linux 系统中重要的文件查找命令。find 命令的功能很强大,其一般使用方法为:
find 位置 -name 文件名称。例如,我要在 / 这个根目录中查找 linux.html 文件,可以执行
find / -name linux.html。你除了可以按文件名称来使用 find 查找文件外,也可以根据文件大小(通过 -size n 选项指定)、时间(如 -atime n 表示查找 n 天前访问过的文件)来搜索文件。 此外,find 命令同样支持在搜索文件时使用正则表达式,你只需指定 -regex 选项即可。
值得注意的是,对于 locate 与 find 这两个命令的解说远非这篇小文所能满足。关于这两个命令的更加详细的用法,你可能需要通过 man locate 或 man find 查询。
相关文章推荐
- Linux内、外部命令的使用、文件权限、文件查找(find、locate、grep)
- Linux命令:文件查找相关 Whereis、find和locate+updatedb
- linux中Find、whereis、locate、which查找文件命令总结
- Linux下文件查找命令which、whereis、locate、find的区别
- Linux下which、whereis、locate、find 命令查找文件
- linux中Find、whereis、locate、which查找文件命令总结
- Linux下查找文件:which、whereis、locate、find 命令的区别
- Linux下which、whereis、locate、find 命令查找文件
- Linux下which、whereis、locate、find 命令查找文件
- Linux文件查找命令详解-which whereis find locate
- linux下查找文件命令总结find、locate、whereis、which、type
- Linux下which、whereis、locate、find 命令查找文件
- 如何查找Linux文件 存放在哪(地点) locate find whereis which 命令
- Linux下which、whereis、locate、find 命令查找文件
- 如何查找Linux文件 存放在哪(地点) locate find whereis which 命令
- Linux文件查找命令find用法整理(locate/find)
- linux下find和locate文件查找命令详解
- linux命令和文件查找之which、whereis、locate、find的特点和区别
- linux中Find、whereis、locate、which查找文件命令详解
- Linux之文件查找命令locate与find详解