首页 > 其他分享 >find命令

find命令

时间:2025-01-07 22:22:57浏览次数:1  
标签:demo bbb Jan 命令 txt root find localhost

[root@localhost ~]# find /demo -maxdepth 1 -name "*.txt"
/demo/aaa.txt
/demo/bbb.txt
/demo/c.txt
/demo/alex.txt
/demo/sort.txt
/demo/sort1.txt
/demo/ip.txt
/demo/luffy.txt
/demo/1alex.txt
/demo/2alex.txt
/demo/3alex.txt
/demo/4alex.txt
/demo/5alex.txt
/demo/6alex.txt
/demo/7alex.txt
/demo/8alex.txt
/demo/9alex.txt
/demo/10alex.txt
[root@localhost ~]# find /demo -maxdepth 2 -name "*.txt"
/demo/aaa.txt
/demo/bbb.txt
/demo/c.txt
/demo/alex.txt
/demo/sort.txt
/demo/sort1.txt
/demo/ip.txt
/demo/luffy.txt
/demo/bbb/ddd.txt
/demo/bbb/{1...10}alex.txt
/demo/1alex.txt
/demo/2alex.txt
/demo/3alex.txt
/demo/4alex.txt
/demo/5alex.txt
/demo/6alex.txt
/demo/7alex.txt
/demo/8alex.txt
/demo/9alex.txt
/demo/10alex.txt
[root@localhost demo]# find . -name "[0-9]*"
./1alex.txt
./2alex.txt
./3alex.txt
./4alex.txt
./5alex.txt
./6alex.txt
./7alex.txt
./8alex.txt
./9alex.txt
./10alex.txt
./1mjj
./2mjj
./3mjj
./4mjj
./5mjj
./6mjj
./7mjj
./8mjj
./9mjj
./10mjj
[root@localhost demo]# find . -type f -name "[0-9]*"
./1alex.txt
./2alex.txt
./3alex.txt
./4alex.txt
./5alex.txt
./6alex.txt
./7alex.txt
./8alex.txt
./9alex.txt
./10alex.txt
[root@localhost demo]# find . -type d -name "[0-9]*"
./1mjj
./2mjj
./3mjj
./4mjj
./5mjj
./6mjj
./7mjj
./8mjj
./9mjj
./10mjj
[root@localhost demo]# find . -type f -name "[0-9]*" -delete
[root@localhost demo]# find . -type f -name "[0-9]*"
[root@localhost demo]# ls -l
total 44
drwxr-xr-x. 2 root root    6 Jan  7 21:31 10mjj
drwxr-xr-x. 2 root root    6 Jan  7 21:31 1mjj
drwxr-xr-x. 2 root root    6 Jan  7 21:31 2mjj
drwxr-xr-x. 2 root root    6 Jan  7 21:31 3mjj
drwxr-xr-x. 2 root root    6 Jan  7 21:31 4mjj
drwxr-xr-x. 2 root root    6 Jan  7 21:31 5mjj
drwxr-xr-x. 2 root root    6 Jan  7 21:31 6mjj
drwxr-xr-x. 2 root root    6 Jan  7 21:31 7mjj
drwxr-xr-x. 2 root root    6 Jan  7 21:31 8mjj
drwxr-xr-x. 2 root root    6 Jan  7 21:31 9mjj
-rw-r--r--. 1 root root 8495 Jan  6 20:52 aaa.txt
-rw-r--r--. 1 root root   54 Jan  6 21:33 alex.txt
drwxr-xr-x. 2 root root   45 Jan  7 21:29 bbb
-rw-r--r--. 1 root root  167 Jan  6 21:18 bbb.txt
-rw-r--r--. 1 root root    7 Jan  6 21:28 c.txt
-rw-r--r--. 1 root root   59 Jan  6 22:38 ip.txt
-rw-r--r--. 1 root root  123 Jan  6 22:53 luffy.txt
-rw-r--r--. 1 root root  938 Jan  6 21:57 password
-rw-r--r--. 1 root root   15 Jan  6 22:31 sort1.txt
-rw-r--r--. 1 root root   36 Jan  6 22:30 sort.txt
[root@localhost demo]# stat alex.txt
  File: ‘alex.txt’
  Size: 54              Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d      Inode: 51354698    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:default_t:s0
Access: 2025-01-06 21:36:45.853159948 +0800
Modify: 2025-01-06 21:33:27.454160705 +0800
Change: 2025-01-06 21:33:27.454160705 +0800
 Birth: -
[root@localhost demo]# find . -atime -1
.
./password
./sort.txt
./sort1.txt
./ip.txt
./luffy.txt
./bbb
./bbb/ddd.txt
./bbb/{1...10}alex.txt
./1mjj
./2mjj
./3mjj
./4mjj
./5mjj
./6mjj
./7mjj
./8mjj
./9mjj
./10mjj
[root@localhost demo]# find . -atime 1
./.aaa.txt.swo
./aaa.txt
./bbb.txt
./c.txt
./alex.txt
[root@localhost demo]# find . -atime +1
[root@localhost demo]# find . -maxdepth 1 ! -type d
./.aaa.txt.swo
./aaa.txt
./bbb.txt
./c.txt
./alex.txt
./password
./sort.txt
./sort1.txt
./ip.txt
./luffy.txt
[root@localhost demo]# find /demo -type f -size +11k
/demo/.aaa.txt.swo
[root@localhost demo]# find /demo -maxdepth 2 -name "*.txt"
/demo/aaa.txt
/demo/bbb.txt
/demo/c.txt
/demo/alex.txt
/demo/sort.txt
/demo/sort1.txt
/demo/ip.txt
/demo/luffy.txt
/demo/bbb/ddd.txt
/demo/bbb/{1...10}alex.txt
[root@localhost demo]# find . -path "./bbb" -prune -o -name "*.txt" -print
./aaa.txt
./bbb.txt
./c.txt
./alex.txt
./sort.txt
./sort1.txt
./ip.txt
./luffy.txt
[root@localhost demo]#  find . -type f -name "[0-9]*"
[root@localhost demo]# touch {1..10}apt.txt
[root@localhost demo]# ls
10apt.txt  1mjj      3apt.txt  4mjj      6apt.txt  7mjj      9apt.txt  alex.txt  c.txt      password
10mjj      2apt.txt  3mjj      5apt.txt  6mjj      8apt.txt  9mjj      bbb       ip.txt     sort1.txt
1apt.txt   2mjj      4apt.txt  5mjj      7apt.txt  8mjj      aaa.txt   bbb.txt   luffy.txt  sort.txt
[root@localhost demo]#  find . -type f -name "[0-9]*"
./1apt.txt
./2apt.txt
./3apt.txt
./4apt.txt
./5apt.txt
./6apt.txt
./7apt.txt
./8apt.txt
./9apt.txt
./10apt.txt
[root@localhost demo]#  find . -type f -name "[0-9]*" -ok rm {} \;
< rm ... ./1apt.txt > ? y
< rm ... ./2apt.txt > ? y
< rm ... ./3apt.txt > ? y
< rm ... ./4apt.txt > ? y
< rm ... ./5apt.txt > ? y
< rm ... ./6apt.txt > ? y
< rm ... ./7apt.txt > ? y
< rm ... ./8apt.txt > ? y
< rm ... ./9apt.txt > ? y
< rm ... ./10apt.txt > ? y
[root@localhost demo]# ls
10mjj  2mjj  4mjj  6mjj  8mjj  aaa.txt   bbb      c.txt   luffy.txt  sort1.txt
1mjj   3mjj  5mjj  7mjj  9mjj  alex.txt  bbb.txt  ip.txt  password   sort.txt

 

标签:demo,bbb,Jan,命令,txt,root,find,localhost
From: https://www.cnblogs.com/wmqxlt/p/18658468

相关文章

  • Java设计模式 —— 【行为型模式】命令模式(Command Pattern) 详解
    文章目录模式介绍优缺点适用场景结构案例实现注意事项模式介绍有时候需要向某些对象发送请求,但是并不知道请求的接收者是谁,也不知道被请求的操作是什么。此时希望用一种松耦合的方式来设计程序,使得请求发送者和请求接收者能够消除彼此之间的耦合关系。拿订餐来说......
  • 【conda基础】虚拟环境及常用conda命令
    @[toc]【conda基础】conda创建虚拟环境及常用conda命令虚拟环境虚拟环境的定义虚拟环境是一个独立的Python运行环境,它包含特定版本的Python解释器及其相关的库和依赖项。虚拟环境与系统的全局Python环境隔离,允许你在同一台机器上为不同的项目创建和管理不同的依赖......
  • Wireshark 是一个强大的网络分析工具,支持使用过滤器来筛选数据包,帮助用户高效地分析和
    Wireshark是一个强大的网络分析工具,支持使用过滤器来筛选数据包,帮助用户高效地分析和排查网络问题。Wireshark的过滤命令可以分为多种类型,以下是按功能分类的常见过滤命令,并以表格的形式展示:Wireshark过滤命令按功能分类类别过滤命令描述协议过滤http过滤HTTP......
  • Linux命令行tar/zip/7z对文件分卷压缩/解压缩
    分为两部分,文件压缩/解压缩和文件校验。1.单文件压缩1.1自动tar#其中'*'替换为'gz','bz2','xz'等.$tar-acfhello.tar.*hello/1.2gz$tar-zcfhello.tar.gzhello/1.3bz2$tar-jcfhello.tar.bz2hello/1.4xz$tar-Jcfhello.ta......
  • vim 编辑 命令 大全
    vim编辑命令大全Vim是一个功能强大的文本编辑器,它拥有许多命令和快捷键。以下是一些常用的Vim命令和快捷键的总结:基本模式切换i或a:进入插入模式(Insertmode)。Esc:退出插入模式,回到普通模式(Normalmode)。普通模式(NormalMode)h、j、k、l:光标左、下、上、右移动。g......
  • 使用Python执行Shell命令并获取结果
    使用Python执行Shell命令并获取结果是一项非常有用的技能,尤其在自动化任务、系统管理和数据处理方面。Python提供了多种方法来运行Shell命令并捕获输出,最常用的是 subprocess模块。以下是如何使用 subprocess模块执行Shell命令并获取结果的详细指南。1.导入 subprocess模块......
  • Linux命令速成
    Linux一、Linux要点要在一个命令行上输入多条命令,可使用分号来分隔命令。比如cd/etc;ls–l。反斜杠“\”将一个较长的命令分成多行表达,换行后,shell自动显示提示符“>”,表示正在输入一个长命令,此时可继续在新行上输入命令的后续部分。Linux命令由”命令+选项+参数“......
  • 【汇总】Android 编译命令
    一、变量、命令、参数排序变量、命令、参数英文说明中文说明备注、示例A    B    C    D    E    F    G    H    I    J    K    L ......
  • linux防火墙相关命令,开启关闭端口,服务,防火墙等
    linux防火墙相关命令,开启关闭端口,服务,防火墙等注意:以下所有命令在centos7.6环境下测试,其他linux环境请自行测试注意:在linux中,不是管理员登录,最好在指令前加上sudo提权,避免权限不够执行失败带来的麻烦,以下命令请都加上sudo,这是一个好习惯。#开启/关闭防火墙systemctlstartfi......
  • nginx常用命令
    nginx常用命令注意:以下所有命令在centos7.6环境下测试,其他linux环境请自行测试注意:在linux中,不是管理员登录,最好在指令前加上sudo提权,避免权限不够执行失败带来的麻烦,以下命令请都加上sudo,这是一个好习惯。常用命令#查看nginx进程是否启动ps-ef|grepnginxpsaux|grep......