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的一些简单命 ...
随机推荐
- Python导入模块的几种方法
Python 模块 Python 模块(Module),是一个 Python 文件,以 .py 结尾,包含了 Python 对象定义和Python语句. 模块让你能够有逻辑地组织你的 Python 代 ...
- P2783 有机化学之神偶尔也会作弊 题解
题面 前言 这道题以前还是道(水)黑题,现在怎么降紫了???? 前置芝士 tarjain 缩点 倍增求LCA或树剖求LCA 脑子... 题意 给你一个无向图,要求你把所有的环缩成一个点.在新得到的图上 ...
- rustup命令速度慢
通过以下命令更换镜像: $ENV:RUSTUP_DIST_SERVER='https://mirrors.ustc.edu.cn/rust-static' $ENV:RUSTUP_UPDATE_ROO ...
- python 中的三种等待方式
为什么要用等待时间: 今天在写App的自动化的脚本时发现一个元素,但是往往执行脚本是报错( An element could not be located on the page using the ...
- 达梦产品技术支持培训-day7-DM8数据库备份与还原-原理
(本文部分内容摘自DM产品技术支持培训文档,如需要更详细的文档,请查询官方操作手册,谢谢) 1.DM8备份还原简介 1.1.基本概念 (1)表空间与数据文件 ▷ DM8表空间类型: ▷ SYSTEM ...
- Elasticsearch(3):别名
ES中可以为索引添加别名,一个别名可以指向到多个索引中,同时在添加别名时可以设置筛选条件,指向一个索引的部分数据,实现在关系数据库汇总的视图功能,这就是ES中别名的强大之处.别名是一个非常实用的功 ...
- 多测师讲解python _函数的传递_高级讲师肖sir
题目: 要求1.通过函数来实现 2.引用函数传递方法 3.引用返回值 有一个登录系统:账号admin 密码123456 验证码abc123 账号.密码.验证码 ...
- linux(centos8):firewalld对于请求会选择哪个zone处理?
一,firewalld对一个请求会适用哪个zone? 当接收到一个请求时,firewalld具体使用哪个zone? firewalld是通过三个步骤来判断的: source,即:源地址 interfa ...
- ps 批量kill进程
Linux下批量kill掉进程 ps -ef|grep java|grep -v grep|cut -c 9-15|xargs kill -9 管道符"|"用来隔开两个命令,管 ...
- matplotlib 饼状图
import matplotlib.pyplot as plt import matplotlib as mpl # 支持中文 plt.rcParams['font.sans-serif'] = [' ...