linux中 locate命令
locate特定:
001:速度快
002:查找依赖于/var/lib/mlocate/mlocate.db
为了时效性查找,在使用locate命令之前可以先更新库: updatedb
示例:
1、locate + file
root@DESKTOP-1N42TVH:/home/test# locate a.txt ## 查找系统中所有包含a.txt的文件 root@DESKTOP-1N42TVH:/home/test# locate a.txt | head /home/test/a.txt /mnt/c/Program Files/Windows NT/TableTextService/TableTextServiceTigrinya.txt /mnt/c/Program Files (x86)/Internet Download Manager/Languages/tips_fa.txt /mnt/c/Program Files (x86)/Microsoft Office/root/Office16/2052/AccessRuntime2019_eula.txt /mnt/c/Program Files (x86)/Microsoft Office/root/Office16/2052/AccessRuntime2021_eula.txt /mnt/c/Program Files (x86)/Microsoft Office/root/Office16/2052/AccessRuntime_eula.txt /mnt/c/Program Files (x86)/Microsoft Office/root/Office16/2052/Client2019_eula.txt /mnt/c/Program Files (x86)/Microsoft Office/root/Office16/2052/Client2021_eula.txt /mnt/c/Program Files (x86)/Microsoft Office/root/Office16/2052/ClientARMRefer2019_eula.txt /mnt/c/Program Files (x86)/Microsoft Office/root/Office16/2052/ClientARMRefer_eula.txt
2、限定查找到的文件的数目
root@DESKTOP-1N42TVH:/home/test# locate -n 3 a.txt ## 限制输出3个 /home/test/a.txt /mnt/c/Program Files/Windows NT/TableTextService/TableTextServiceTigrinya.txt /mnt/c/Program Files (x86)/Internet Download Manager/Languages/tips_fa.txt
3、 查找目录中以sh开头的文件
root@DESKTOP-1N42TVH:/home/test# locate /bin/sh ## 查找目录中以sh开头的文件 /mnt/d/programs/Git/bin/sh.exe /mnt/d/programs/Git/usr/bin/sh.exe /mnt/d/programs/Git/usr/bin/sha1sum.exe /mnt/d/programs/Git/usr/bin/sha224sum.exe
4、-i忽略大小写查找
root@DESKTOP-1N42TVH:/home/test# ls a.txt xYAbzM.txt xyabzm.txt root@DESKTOP-1N42TVH:/home/test# locate xyabzm.txt /home/test/xyabzm.txt root@DESKTOP-1N42TVH:/home/test# locate xyabzm.txt -i ## -i忽略大小写进行查找 /home/test/xYAbzM.txt /home/test/xyabzm.txt
5、-c选项统计查找到的数量
root@DESKTOP-1N42TVH:/home/test# ls a.txt xYAbzM.txt xyabzm.txt root@DESKTOP-1N42TVH:/home/test# locate xyabzm.txt /home/test/xyabzm.txt root@DESKTOP-1N42TVH:/home/test# locate -c xyabzm.txt 1 root@DESKTOP-1N42TVH:/home/test# locate -i xyabzm.txt /home/test/xYAbzM.txt /home/test/xyabzm.txt root@DESKTOP-1N42TVH:/home/test# locate -c -i xyabzm.txt ## -i表示忽略大小写, -c表示统计数目 2
6、-r选项用于正则表达式
root@DESKTOP-1N42TVH:/home/test# ls a.txt xYAbzM.txt xyabzm.txt root@DESKTOP-1N42TVH:/home/test# locate -r xy* ## 查找以xy开头的行 /home/test/xyabzm.txt root@DESKTOP-1N42TVH:/home/test# locate -r xY* ## 查考以xY开头的行 /home/test/xYAbzM.txt root@DESKTOP-1N42TVH:/home/test# locate -r zm.txt$ ## 查考以zm.txt结尾的行 /home/test/xyabzm.txt
参考:https://www.jb51.net/article/180941.htm
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
2021-04-30 c语言 5-11
2021-04-30 c语言 5-10 求4行3列矩阵和3行4列矩阵的乘积。各构成元素的值从键盘输入。