定位、查找文件
程序员文章站
2022-07-12 09:13:42
...
1.which command(在path中找第一个)
[[email protected] /]# which ls
alias ls='ls --color=auto'
/usr/bin/ls
2.whereis [option]name
[[email protected] /]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
[[email protected] /]# whereis -b ls
ls: /usr/bin/ls
[[email protected] /]# whereis -m ls
ls: /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz
[[email protected] /]# whereis -s ls
ls:[[email protected] /]#
3.find path -name [文件名]
[[email protected] 桌面]# ls m*
my mylove mysql
[[email protected] /]# find /home/260254/桌面 -name my*
/home/260254/桌面/my
/home/260254/桌面/mylove
/home/260254/桌面/mysql
[[email protected] /]# find /home/260254/桌面 -name my?
[[email protected] /]# find /home/260254/桌面 -name my???
/home/260254/桌面/mysql
[[email protected] /]# find /home/260254/桌面 -name my[ls]
[[email protected] /]# find /home/260254/桌面 -name my[ls]ove
/home/260254/桌面/mylove
[[email protected] /]# find /home/260254/桌面 -name my[ls]q
[[email protected] /]# find /home/260254/桌面 -name my[ls]ql
/home/260254/桌面/mysql
更多详细内容请参考find的用法
4.locate name
[[email protected] 桌面]# ls 国家
国家
[[email protected] 桌面]# locate 国
/home/260254/桌面/国家
更多详细内容请参考locate的用法