linux 查找文件 locate,linux文件查找(find,locate)
文件查找:
locate:
非实时,模糊匹配,查找是根据全系统文件数据库进行的;
# updatedb, 手动生成文件数据库
速度快
find:
实时
精确
支持众多查找标准
遍历指定目录中的所有文件完成查找,速度慢;
find 查找路径 查找标准 查找到以后的处理运作
查找路径:默认为当前目录
查找标准:默认为指定路径下的所有文件
处理运作:默认为显示
匹配标准:
-name 'FILENAME':对文件名作精确匹配
文件名通配:
*:任意长度的任意字符
?
[]
-iname 'FILENAME': 文件名匹配时不区分大小写
-regex PATTERN:基于正则表达式进行文件名匹配
-user USERNAME: 根据属主查找
-group GROUPNAME: 根据属组查找
-uid UID: 根据UID查找
-gid GID: 根据GID查找
-nouser:查找没有属主的文件
-nogroup: 查找没有属组的文件
-type
f: 普通文件
d
c
b
l
p
s
-size [+|-]
#k
#M
#G
/tmp目录,不是目录,并且还不能套接字类型的文件
/tmp/test目录下,属主不是user1,也不是user2的文件;
-mtime 修改时间
-ctime
-atime 访问时间
[+|-]#
-mmin
-cmin
-amin
[+|-]#
解释-atime 5 表示距离此刻刚好五天的
-atime +5 表示距离此刻大于五天都没访问过的
-atime -5 表示距离此刻五天之内有访问过的
-perm MODE:精确匹配
/MODE: 任意一位匹配即满足条件
-MODE: 文件权限能完全包含此MODE时才符合条件
-644
644: rw-r--r--
755: rwxr-xr-x
750: rwxr-x---
find ./ -perl -001
运作:
-print: 显示
-ls:类似ls -l的形式显示每一个文件的详细
-ok COMMAND {} \; 每一次操作都需要用户确认
-exec COMMAND {} \;
运作例子:{}表示匹配到的内容
[root@data-1-3 scripts]# find . -amin -30 -exec chmod u-w {} \;
[root@data-1-3 scripts]# ll
total 20
-rwxr-xr-x 1 root root 280 Jan 7 11:55 1.sh
-r--r--r-- 1 root root 0 Jan 8 08:03 a
-rwxr-xr-x 1 root root 168 Jan 7 11:13 jiou_sum.sh
-rwxr-xr-x 1 root root 261 Jan 8 03:30 sum.sh
-rwxr-xr-x 1 root root 222 Jan 7 17:42 user01.sh
-rwxr-xr-x 1 root root 489 Jan 7 18:24 user.sh
[root@data-1-3 scripts]# find . -amin -30 -ok chmod u+w {} \;
< chmod ... . > ? y
< chmod ... ./a > ? y
[root@data-1-3 scripts]# ll
total 20
-rwxr-xr-x 1 root root 280 Jan 7 11:55 1.sh
-rw-r--r-- 1 root root 0 Jan 8 08:03 a
-rwxr-xr-x 1 root root 168 Jan 7 11:13 jiou_sum.sh
-rwxr-xr-x 1 root root 261 Jan 8 03:30 sum.sh
-rwxr-xr-x 1 root root 222 Jan 7 17:42 user01.sh
-rwxr-xr-x 1 root root 489 Jan 7 18:24 user.sh
改文件名:
[root@data-1-3 scripts]# find -perm 644
./a
[root@data-1-3 scripts]# find -perm 644 -exec mv {} {}.new \;
[root@data-1-3 scripts]# ll
total 20
-rwxr-xr-x 1 root root 280 Jan 7 11:55 1.sh
-rw-r--r-- 1 root root 0 Jan 8 08:03 a.new
-rwxr-xr-x 1 root root 168 Jan 7 11:13 jiou_sum.sh
-rwxr-xr-x 1 root root 261 Jan 8 03:30 sum.sh
-rwxr-xr-x 1 root root 222 Jan 7 17:42 user01.sh
-rwxr-xr-x 1 root root 489 Jan 7 18:24 user.sh
再一个例子:将大于1M的文件找出并追加到/tmp/etc.largesfile
[root@data-1-3 scripts]# find /etc/ -size +1M
/etc/pki/tls/certs/ca-bundle.trust.crt
/etc/selinux/targeted/policy/policy.24
/etc/selinux/targeted/modules/active/policy.kern
[root@data-1-3 scripts]# find /etc/ -size +1M |xargs >> /tmp/etc.largesfile
[root@data-1-3 scripts]# cat /tmp/etc.largesfile
/etc/pki/tls/certs/ca-bundle.trust.crt /etc/selinux/targeted/policy/policy.24 /etc/selinux/targeted/modules/active/policy.kern
[root@data-1-3 scripts]# find /etc/ -size +1M -exec echo {} >> /tmp/etc.largesfile \; [root@data-1-3 scripts]# cat /tmp/etc.largesfile
/etc/pki/tls/certs/ca-bundle.trust.crt /etc/selinux/targeted/policy/policy.24 /etc/selinux/targeted/modules/active/policy.kern
/etc/pki/tls/certs/ca-bundle.trust.crt
/etc/selinux/targeted/policy/policy.24
/etc/selinux/targeted/modules/active/policy.kern
##############################################################
[root@data-1-3 scripts]# stat a
File: `a'
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd00h/64768d Inode: 131939 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2017-01-08 08:03:12.990058301 +0800
Modify: 2017-01-08 08:03:07.122074618 +0800
Change: 2017-01-08 08:03:12.990058301 +0800
[root@data-1-3 scripts]# find -amin -5 -ls
143757 4 drwxr-xr-x 2 root root 4096 Jan 8 08:03 .
131939 0 -rw-r--r-- 1 root root 0 Jan 8 08:03 ./a
[root@data-1-3 scripts]# find -atime -5 -ls
143757 4 drwxr-xr-x 2 root root 4096 Jan 8 08:03 .
131939 0 -rw-r--r-- 1 root root 0 Jan 8 08:03 ./a
140442 4 -rwxr-xr-x 1 root root 168 Jan 7 11:13 ./jiou_sum.sh
140514 4 -rwxr-xr-x 1 root root 222 Jan 7 17:42 ./user01.sh
140515 4 -rwxr-xr-x 1 root root 261 Jan 8 03:30 ./sum.sh
140448 4 -rwxr-xr-x 1 root root 280 Jan 7 11:55 ./1.sh
140513 4 -rwxr-xr-x 1 root root 489 Jan 7 18:24 ./user.sh
linux文件查找工具——locate,find
一文件查找介绍 文件的查找就是在文件系统上查找符合条件的文件. 文件查找的方式:locate, find非实时查找也就是基于数据库查找的locate,效率特别高. 实时查找:find 二locate ...
Linux文件查找命令find用法整理(locate/find)
Linux文件查找查找主要包括:locate和find 1.locate 用法简单,根据数据库查找,非实时,用法: locate FILENAME 手动更新数据库(时间可能较长) updatedb 2 ...
linux 文件查找,which,whereis,locate,find
linux 文件查找,which,whereis,locate,find 一:which 主要用于查找可执行命令的所在位置: 如图,查找命令 ls的目录: 二:whereis 主要用于查找命令的帮助文 ...
Linux操作系统的文件查找工具locate和find命令常用参数介绍
Linux操作系统的文件查找工具locate和find命令常用参数介绍 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.非实时查找(数据库查找)locate工具 locate命 ...
Linux文件查找.md
Linux 文件查找 在Linux系统的查找相关的命令: which 查看可执行文件的位置 whereis 查看文件的位置 locate 配合数据库查看文件位置 find 实际搜寻硬盘查询文件名称 w ...
linux文件查找find命令
linux文件查找find命令 1.文件查找 基本介绍 在文件系统上查找符合条件的文件 linux上常见的文件查找工具:find命令 查找分类 实时查找 精确查找 基本语法 find [option ...
Linux文件查找命令find,xargs详述【转】
转自:http://blog.csdn.net/cxylaf/article/details/4069595 转自http://www.linuxsir.org/main/?q=node/137 Li ...
【Linux相识相知】文件查找(locate/find)
在用linux操作系统的时候,当我们忘记之前某个文件存储的位置,但是知道其文件名或者模糊的知道其文件名,我们都可以通过文件查找工具来查找,linux提供两种常用的查找工具,locate和find,在日 ...
Linux文件查找find和locate
目 录 第1章 locate文件查找 1 1.1 概述 1 1.2 locate文件查找的特性 1 第2章 文件查找概述 1 第3章 1 3.1 文件名查找 1 3 ...
随机推荐
FNV哈希算法
由来:FNV哈希算法全名为Fowler-Noll-Vo算法,是以三位发明人Glenn Fowler,Landon Curt Noll,Phong Vo的名字来命名的,最早在1991年提出. 特点和用途 ...
java中的list,set,数组之间的转换
使用该工具类import org.apache.commons.collections.CollectionUtils; 在Apache Jakarta Commons Collections中 St ...
Android 动态加载 (三) PAK 详解
pak文件经常出现于游戏的安装目录中,其实pak文件是一种特殊的游戏压缩文件,用于压缩声音.图片等资料.由于pak文件专门针对游戏设计文件结构,pak文件就是将多个文件(图片.音乐.文本)打包为一个单 ...
机器学习笔记:Gradient Descent
机器学习笔记:Gradient Descent http://www.cnblogs.com/uchihaitachi/archive/2012/08/16/2642720.html
[转]ubuntu环境变量配置文件
参考网址:http://www.bkjia.com/Linuxjc/1008127.html Ubuntu通常使用的几个配置文件主要有下面这几个: /etc/environment./etc/prof ...
【HeadFirst设计模式】10.状态模式
定义: 允许对象在内部状态改变时改变它 行为,对象看起来好像修改了它的类. OO原则: 封装变化 多用组合,少用继承 针对接口编程,不针对实现编程 为交互对象之间的松耦合设计而努力 类应该对扩展开放, ...
Android Activity与Service的交互方式
参考: http://blog.csdn.net/gebitan505/article/details/18151203 实现更新下载进度的功能 1. 通过广播交互 Server端将目前的下载进度,通 ...
Struts2之2.5.10.1HelloWorld
Struts2.5.10.1是目前为止最新的版本,struts2建议持续跟进,理由大家都懂.好了,下面步入正题. 基于struts2.5.10.1建立一个HelloWorld,基于注解的哈! 工具:e ...
testng-result中文乱码问题
背景 执行完用例查看报告,发现testng-result.xml文件中关于中文的都是乱码 解决方法 eclipse已设置了utf-8去编译,所以直接运行run as testng ,在console栏 ...
linux 查找文件 locate,linux文件查找(find,locate)相关推荐
- linux 查找文件locate,Linux locate命令:按照文件名搜索文件
whereis 和 which 命令都是只能搜索系统命令的命令,而 locate 命令才是可以按照文件名搜索普通文件的命令. 但是 locate 命令的局限也很明显,它只能按照文件名来搜索文件,而不能 ...
- Linux文件查找命令具体解释-which whereis find locate
原创BLog.转载请注明出处 http://blog.csdn.net/hello_hwc? viewmode=contents which命令 首先查看man which的说明 which - sh ...
- linux j查找文件位置,Linux下的文件查找命令——find
Linux下几个常见的文件查找命令: which 查看可执行文件的位置 whereis 寻找特定文件,查看文件的位置 locate 配合数据库查看文件位置 find ...
- linux搜索有哪些文件夹,Linux常见几个查找命令
以下命令是很久以前学习Linux,网上查到的命令自己做了下总结.记录在这里方便以后查看. Linux常见五种查找命令 1.which which命令的作用是,在PATH变量指定的路径中,搜索某个系统命 ...
- linux系统文件查找实验报告,Linux 文件查找与打包
Linux运维与DevOps实战-实验7 一.find # find 命令在目录层次下搜寻查找一个文件 # 并且会打印所找到文件的有关信息 # 语法 find [path...] [expressio ...
- linux查找文件限制时间,Linux查找命令find与文件三种时间
Linux中查找命令如下: Which 查看可执行文件的位置. whereis 查看文件的位置. locate 配合数据库查看文件位置. Find 实际搜寻硬盘查询文件名称. 其中find的功能很强大 ...
- linux查看进程运行日志文件,【Linux】常用指令、ps查看进程、kill杀进程、启动停止tomcat命令、查看日志、查看端口、find查找文件...
1.说出 10 个 linux 常用的指令 1) ls 查看目录中的文件 2)cd /home 进入 '/ home' 目录:cd .. 返回上一级目录:cd ../.. 返回上两级目录 3)mkdi ...
- linux下如何搜索某个文件,技术|如何在 Linux 中查找一个文件
对于新手而言,在 Linux 中使用命令行可能会非常不方便.没有图形界面,很难在不同文件夹间浏览,找到需要的文件.本篇教程中,我会展示如何在 Linux 中查找特定的文件. 第一步要做的是find 命 ...
- 实训|第十一天学习一下linux中的进程,文件查找,文件压缩与IO重定向
[root@localhost~]#序言 在今后的工作中,运维工程师每天的例行事务就是使用free -m,top,uptime,df -h...每天都要检查一下服务器,看看是否出现异常.那么今天我们就 ...
最新文章
- phpMyAdmin安装图解教程
- OpenTsdb官方文档-----理解指标和时间序列
- android 点击edittext全选,Android - 阻止edittext复制/粘贴,然后双击全选
- Spring IOC示例代码
- vector模板,初学者必读
- leetcode - Balanced Binary Tree
- 从.Net到Java学习第四篇——spring boot+redis
- Mr.J-- HTTP学习笔记(四)-- 连接管理
- Currency Exchange (POJ 1860)
- 提取过程_上海生物发酵展浅谈中药提取分离的现状
- docker基础容器中bash: vi: command not found问题解决
- [基础篇]PHP引用变量
- CAB无法连接到远程计算机,当您使用远程桌面连接 (RDC) 7.0 连接不正确地更新远程应用程序应用程序中的组合框项...
- wps for linux字体缺失,wps for linux 字体库缺失问题的解决办法
- 连享会新命令 lxh:随时查看 Stata 资源
- 关于win11右键的慢问题的建议
- ORACLE账户提示EXPIRED(GRACE)问题解决
- CoreOS容器云企业实战(3)--Docker技术实践
- Java面试:数据库,Java,框架,前端技术。应有尽有
- 大鹏背景,大鹏为什么能邀请那么多明星?揭秘董成鹏的成名路
热门文章
- App后台开发运维和架构实践学习总结(10)——基于Java-JWT前后端token认证实战使用详解
- zabbix之解决中文乱码
- MSSQL调优实战一 乱建聚集索引的后果
- Java并发之线程池ThreadPoolExecutor源码分析学习
- Cmder 设置默认打开目录、解决中文乱码
- 全国首个园区型绿色能源网一年“减碳”上万吨
- Hibernate初始化创建SessionFactory,Session,关闭SessonFactory,session
- 医药电商为何发展不起来?
- LA 3263 That Nice Euler Circuit (2D Geometry)
- 【挨踢人物传】tao61:做一个许三多式的IT攻城狮(第2期)