find命令的简单使用
Find命令
格式:find [option] [Path] [筛选条件] [处理动作]
Path:默认当前目录
筛选条件:对文件/目录设置筛选条件
处理动作:默认显示所有文件
筛选条件:
-name Name文件或目录名称,区分大小写
-iname Name不区分大小写
-user User_Name利用文件属主筛选
-group Group_Name利用文件属组筛选
-uid UID利用UID进行筛选,当用户被删除时,只有用户的UID留在文件/目录上,没有用户名显示
-gid GID利用GID进行筛选,当组被删除时,只用GID留在文件/目录上,没有组名显示
-nouser被删除用户所留下的文件
-nogroup被删除的组所留下的文件
-size [+|-] n [unit]
+|-
-size n [unit]n-1至n个单位的文件
-size +n [unit]大于n+1个单位的文件
-size -n [unit]小于n-1个单位的文件
unit
c比特 kKB MMB GGB
以文件类型为筛选条件-type TYPE
TYPE:f普通文件 d目录 b块设备 c字符设备 l符号链接 p命令管道 s套接字
以时间戳为筛选条件
以天计:--------------(now-n-1)--------------(now-n)--------------now---->
-atime [+|-] n时分秒单位依然有效
-atime n(now-n-1)至(now-n)
-atime -n(now-n)至(now)内被访问到
-atime +n(now-n-1)以前
-mtime [+|-] n同atime
-ctime [+|-] n同atime
[root@ZYB test_dir1]# date
Wed Apr 25 09:05:23 CST 2018
[root@ZYB test_dir2]# ls
test_file00 test_file01 test_file10 test_file11 test_file20 test_file21
[root@ZYB test_dir1]# touch -mt "04220700.00" test_file00
[root@ZYB test_dir1]# touch -mt "04221300.00" test_file01
[root@ZYB test_dir1]# touch -mt "04230700.00" test_file10
[root@ZYB test_dir1]# touch -mt "04231300.00" test_file11
[root@ZYB test_dir1]# touch -mt "04240700.00" test_file20
[root@ZYB test_dir1]# touch -mt "04241300.00" test_file21
[root@ZYB test_dir1]# stat test_file* | grep "Mod"
Modify: 2018-04-22 07:00:00.000000000 +0800
Modify: 2018-04-22 13:00:00.000000000 +0800
Modify: 2018-04-23 07:00:00.000000000 +0800
Modify: 2018-04-23 13:00:00.000000000 +0800
Modify: 2018-04-24 07:00:00.000000000 +0800
Modify: 2018-04-24 13:00:00.000000000 +0800
[root@ZYB test_dir1]# find -mtime 1
./test_file20
./test_file11
[root@ZYB test_dir1]# find -mtime -1
.
./test_file21
[root@ZYB test_dir1]# find -mtime -2
.
./test_file20
./test_file21
./test_file11
[root@ZYB test_dir1]# find -mtime +2
./test_file00
以分钟计:--------------(now-x)--------------(now-x+1)--------------now---->
-amin [+|-] n秒单位依然有效
-amin x(now-x)至(now-x+1)
-amin -x(now-x)至(now)
-amin +x(now-x)以前
-mmin [+|-] x同amin
-cmin [+|-] x同amin
[root@ZYB test_dir2]# ls
test_file00 test_file03 test_file10 test_file13 test_file20 test_file23
test_file01 test_file04 test_file11 test_file14 test_file21 test_file24
test_file02 test_file05 test_file12 test_file15 test_file22 test_file25
[root@ZYB test_dir2]# stat test_file0? | grep "Modify"
Modify: 2018-04-25 08:29:05.000000000 +0800
Modify: 2018-04-25 08:29:15.000000000 +0800
Modify: 2018-04-25 08:29:25.000000000 +0800
Modify: 2018-04-25 08:29:35.000000000 +0800
Modify: 2018-04-25 08:29:45.000000000 +0800
Modify: 2018-04-25 08:29:55.000000000 +0800
[root@ZYB test_dir2]# stat test_file1? | grep "Modify"
Modify: 2018-04-25 08:30:05.000000000 +0800
Modify: 2018-04-25 08:30:15.000000000 +0800
Modify: 2018-04-25 08:30:25.000000000 +0800
Modify: 2018-04-25 08:30:35.000000000 +0800
Modify: 2018-04-25 08:30:45.000000000 +0800
Modify: 2018-04-25 08:30:55.000000000 +0800
[root@ZYB test_dir2]# stat test_file2? | grep "Modify"
Modify: 2018-04-25 08:31:05.000000000 +0800
Modify: 2018-04-25 08:31:15.000000000 +0800
Modify: 2018-04-25 08:31:25.000000000 +0800
Modify: 2018-04-25 08:31:35.000000000 +0800
Modify: 2018-04-25 08:31:45.000000000 +0800
Modify: 2018-04-25 08:31:55.000000000 +0800
[root@ZYB test_dir2]# date
Wed Apr 25 08:48:19 CST 2018
[root@ZYB test_dir2]# find -mmin 18
./test_file20
./test_file21
./test_file15
./test_file13
./test_file14
./test_file12
[root@ZYB test_dir2]# date
Wed Apr 25 08:53:31 CST 2018
[root@ZYB test_dir2]# find -mmin -19
.
./test_file20
./test_file21
./test_file15
./test_file24
./test_file13
./test_file14
./test_file23
./test_file25
./test_file22
[root@ZYB test_dir2]# date
Wed Apr 25 08:49:33 CST 2018
[root@ZYB test_dir2]# find -mmin +23
./test_file02
./test_file11
./test_file00
./test_file04
./test_file10
./test_file12
./test_file01
./test_file05
./test_file03
以权限为筛选条件-perm [+|-] MODE
-perm MODE精确匹配
-perm +MODE任意用户类型的任意指定权限位,-要被/所取代
-perm -MODE指定用户类型指定权限位
筛选条件组合时,括号需转义
[root@ZYB ~]# find /usr/ -not -user root -not -user bin -ls
2102377 0 -rw-r--r-- 1 zyb zyb 0 Apr 24 20:18 /usr/haha
[root@ZYB ~]# find /usr/ -not \( -user root -o -user bin \) -ls
2102377 0 -rw-r--r-- 1 zyb zyb 0 Apr 24 20:18 /usr/haha
# -not空格\(空格-user空格root空格-o空格-user空格bin空格\) 空格不能省略
处理动作:
-print打印到标准输出上
-ls以长格式形式显示
-exec COMMAND {} \;使用于对查找到的内容进行处理,反斜号为转义字符,花括号与反斜线之间用空格
[root@ZYB test_dir1]# ls
test_file1 test_file2
[root@ZYB test_dir1]# find -name "tes*" -exec mv {} {}_haha \;
-ok COMMAND {} \;交互模式,同-exec,但在进行操作之前需用户确认所执行的命令
-xargs COMMAND对查找内容进行操作
find命令的简单使用的更多相关文章
- DOS命令行简单用法
DOS命令行简单用法 基本用法 1.cd(回车)从当前目录切回到根目录. 2.dir(回车)列出当前目录下的所有文件. 3.md kkk(回车)在当前目录下创建一个名称为kkk的文件夹. 4.rd k ...
- kill命令的简单实现
kill命令的简单实现 目标:简单实现kill命令 功能: 向进程发送信号 列出信号名字 参数: -l 列出信号名字 -s (s=1.2.3.....)发送的信号代号 环境 ubuntu 14.04 ...
- ls命令的简单实现
ls命令的简单实现 目标:简单的实现ls命令 实现的mic_ls命令主要功能 1.循环遍历目录 2.列出目标目录所有的子目录和文件 3.列出文件的文件权限,所有者,文件大小等详细信息 参数 -r 循环 ...
- cat命令的简单实现
cat命令的简单实现 目标:简单的实现cat命令 实现的mic_cat命令主要有三大功能 1.mic_cat命令一次显示整个文件 $ mic_cat filename 2.mic_cat命令从键盘创建 ...
- 【终端使用】用户权限和"chmod"命令的简单使用
一.用户权限知识点 1.1.基本概念 用户是Linux系统工作中重要的一环,用户管理包括 用户管理 和 组管理. 在Linux系统中,不论由本机登录系统 或者 远程登录系统,每个系统都必须拥有一个账号 ...
- 7z命令行简单使用
7z命令行简单使用 网上有很多博客都有记录7z的命令行使用方式,但看起来乱起八糟的,不知所云. 急于使用者可以直接看实例 注:我仅仅记录我认为常用的命令,毕竟没有那么多的精力去学习不常用的东西. 简介 ...
- 如何通过命令行简单的执行C程序
如何通过命令行简单的执行C语言编写的程序 首先,我们知道C语言程序都是以xxx.c结尾的,这在Windows系统和Linux系统都是一样的.其次,C程序的执行过程为四步:预处理--编译--汇编-- ...
- Fedora/Centos使用dnf/yum为Firefox安装Flash,两行命令超简单
Fedora/Centos使用dnf/yum为Firefox安装Flash,两行命令超简单 Flash已死,我想这个方法应该已经失效了吧,毕竟是从adobe的官方下载的,应该是撤链接了,我也很久没安装 ...
- 支持 dd 命令的简单的 GUI 实用程序
Kindd-支持 dd 命令的简单的 GUI 实用程序 "Kindd",一个属于dd 命令的图形化前端.它是自由开源的.用 Qt Quick 所写的工具.总的来说,这个工具对那些对 ...
- windbg 基础命令实战 - 简单程序破解
以前玩游戏遇到一些实在过不去的管卡,经常会找一些游戏修改软件来修改游戏,让自己变得无比强大,将boss一路砍瓜切菜过足游戏瘾.其实游戏修改软件的功能大多都比较简单,我们可以通过windbg的一些简单命 ...
随机推荐
- 路由总结之静态、RIP、OSPF、IS-IS、BGP和策略路由
路由无疑是当今网络的核心,看到浩如烟海的网络资料,可以让人皓首穷经啊,而且都是浩浩荡荡几百页,所以想搞简单点. 静态路由 静态路由无疑是最简单,也是最基本的. Ip route-static(指定是静 ...
- python数据结构之二叉树的建立实例
先建立二叉树节点,有一个data数据域,left,right 两个指针域 # coding:utf-8 class TreeNode(object): def __init__(self,left=N ...
- 独立看第一个C++程序到最终结果log----2019-04-15
本文纯为本人记录,有网上诸多参考,请勿转发! 记录可能可能有点啰嗦,自己划重点吧!! (无论是生活还是工作,如果很困惑,千万不要消极一定要勇敢积极的面对它,不用说太多懂得人自然懂,一定要解决这个疑惑就 ...
- 《C++ primerplus》第13章练习题
1.对CD类的派生练习.基类CD类存储作者和作品号等信息,派生类Classic额外增加一格"主要作品"的信息.主函数使用拷贝构造函数.按引用传递参数的函数和指针来测试基类和派生类的 ...
- Trie树【字典树】浅谈
最近随洛谷日报看了一下Trie树,来写一篇学习笔记. Trie树:支持字符串前缀查询等(目前我就学了这些qwq) 一般题型就是给定一个模式串,几个文本串,询问能够匹配前缀的文本串数量. 首先,来定义下 ...
- MySQL基础 :基本知识点大纲
- Linux执行脚本让进程挂掉后自动重启
1 创建循环监听脚本 autostart.sh 例: 其中futures-market-server-v3andwebsoket.jar 是要监听的执行程序 #/bin/bashwhile true ...
- 多测师讲解htm_L标题标签001_高级讲师 肖sir
<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>百 ...
- 基于python实现二叉树的遍历
""" 二叉树实践: 用递归构建树的遍历 # 思路分析 -- 1.使用链式存储,一个Node表示一个数的节点 -- 2.节点考虑使用两个属性变量,分别表示左连接右连接 & ...
- 【原创】xenomai内核解析--xenomai与普通linux进程之间通讯XDDP(三)--实时与非实时数据交互
版权声明:本文为本文为博主原创文章,转载请注明出处.如有问题,欢迎指正.博客地址:https://www.cnblogs.com/wsg1100/ 目录 1.概述 1.概述 [原创]实时IPC概述 [ ...