linux 系统提供了 5 个搜索文件命令:
$ whereis
在 数据库 /var/lib/mlocate/ 中查找, 每天通过 updatadb命令 更新数据库
$ locate
一般使用 locate -b "\ls" 同 whereis
$ which
一般是在 $PATH 路径下搜索,一般应用于 搜索可执行文件 eg:which gcc
$ type
用于判断一个命令是否属于 shell 内置, -p 选项相当于 which 命令
$ find
eg: find / -mtime -1 -exec ls -l {} \;
{} 是占位符
\; “;" 在 bash 中有特殊含义,需要用 "\" 来进行转义
-exec 是 find 命令对找到的文件执行的动作
find / -mtime 3 // 找到3天前的那天发生变化的所有文件
find / -mtime -3 // 找到3天内发生变化的所有文件
find / -mtime +3 // 找到3天前发生变化的所有文件
$ whereis
在 数据库 /var/lib/mlocate/ 中查找, 每天通过 updatadb命令 更新数据库
$ locate
一般使用 locate -b "\ls" 同 whereis
$ which
一般是在 $PATH 路径下搜索,一般应用于 搜索可执行文件 eg:which gcc
$ type
用于判断一个命令是否属于 shell 内置, -p 选项相当于 which 命令
$ find
eg: find / -mtime -1 -exec ls -l {} \;
{} 是占位符
\; “;" 在 bash 中有特殊含义,需要用 "\" 来进行转义
-exec 是 find 命令对找到的文件执行的动作
find / -mtime 3 // 找到3天前的那天发生变化的所有文件
find / -mtime -3 // 找到3天内发生变化的所有文件
find / -mtime +3 // 找到3天前发生变化的所有文件