首页 » PHP教程 » php查找文本代码技巧_shell文本操作find查找敕令

php查找文本代码技巧_shell文本操作find查找敕令

访客 2024-11-06 0

扫一扫用手机浏览

文章目录 [+]

[root@bogon mnt]# find . -name '.txt'找到所有包含txt的文件./file3.txt./file2.txt./file1.txt./user.txtfind . -name \"大众[0-9]\"大众在当前目录下找以数字开头的文件

示例:

[root@bogon mnt]# find . -name 'file[0-9]'利用正则表达式查找包含file文件有0-9的所有文件./file6.ppt./file4.doc./file3.txt./file5.xls./file2.txt./file1.txt./file7.txt./file8.txt./file9.txtfind / -name \"大众host\公众在根目录下找以host开头的文件

示例:

php查找文本代码技巧_shell文本操作find查找敕令

查找网卡文件,同理可查找其它根目录下任意文件

php查找文本代码技巧_shell文本操作find查找敕令
(图片来自网络侵删)

[root@bogon mnt]# find / -name ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-eth0find . -perm 755在当前目录下找属性为755的文件

示例:

[root@bogon mnt]# lltotal 8-rw-r--r--. 1 root root 0 Sep 20 20:32 file1.txt-rw-r--r--. 1 root root 0 Sep 20 20:32 file2.txt-rw-r--r--. 1 root root 0 Sep 20 20:32 file3.txt-rw-r--r--. 1 root root 0 Sep 20 20:32 file4.doc-rw-r--r--. 1 root root 0 Sep 20 20:32 file5.xls-rw-r--r--. 1 root root 0 Sep 20 20:32 file6.ppt-rw-r--r--. 1 root root 0 Sep 20 20:41 file7.txt-rw-r--r--. 1 root root 0 Sep 20 20:41 file8.txt-rw-r--r--. 1 root root 0 Sep 20 20:44 file9.txt-rwxrwxrwx. 1 root root 0 Sep 20 20:40 linux.txt-rwxr-xr-x. 1 root root 0 Sep 20 20:40 php.txt-rwxr-xr-x. 1 root root 1324 Oct 10 2018 test.sh-rw-r--r--. 1 root root 155 Sep 20 11:18 user.txt-rw-------. 1 root root 0 Sep 20 20:40 web.txt[root@bogon mnt]# find . -perm 755../php.txt./test.sh[root@bogon mnt]# find . -perm 777./linux.txt[root@bogon mnt]# find . -perm 644./file6.ppt./file4.doc./file3.txt./file5.xls./file2.txt./file1.txt./file7.txt./file8.txt./user.txt./file9.txt[root@bogon mnt]# find . -perm 600./web.txtfind -user root在当前目录下找属主为root的文件

示例:

[user1@bogon mnt]$ find -user user1./user1-4.txt./user1-1.txt./user1-2.txt./user1-3.txt[user1@bogon mnt]$ find -user root../file6.ppt./file4.doc./file3.txt./file5.xls./php.txt./file2.txt./linux.txt./file1.txt./file7.txt./test.sh./file8.txt./web.txt./user.txt./file9.txt[user1@bogon mnt]$ lsfile1.txt file4.doc file7.txt linux.txt user1-1.txt user1-4.txtfile2.txt file5.xls file8.txt php.txt user1-2.txt user.txtfile3.txt file6.ppt file9.txt test.sh user1-3.txt web.txtfind /etc -mtime -1在/etc下找变动韶光在1天以内的文件

示例:

[root@bogon ~]# find /etc -mtime -1|wc -l11find /etc -mtime +1在/etc下找变动韶光在1天以前的文件

示例:

[root@bogon ~]# find /etc -mtime +1|wc -l392find /etc -type d或l在etc下找文件类型为d的目录文件或文件类型为l的链接文件

示例:

[root@bogon ~]# find /etc -type d|wc -l128[root@bogon ~]# find /etc -type l|wc -l195find . -size -1000000c在当前目录下查找文件小于1M的文件

示例:

[root@bogon mnt]# find . -size -1000000c../file6.ppt./dir1./file4.doc./file3.txt./file5.xls./php.txt./file2.txt./linux.txt./file1.txt./file7.txt./test.sh./file8.txt./web.txt./file9.txtfind . -type f|xargs ls -l查找出文件并查看其详细信息

示例:

找出在mnt目录下包含user的文件并进行删除,同理可利用该命令实行其它操作

[root@bogon ~]# find /mnt/ -name 'user'/mnt/user1-4.txt/mnt/user1-1.txt/mnt/user1-2.txt/mnt/user.txt/mnt/user1-3.txt[root@bogon ~]# find /mnt/ -name 'user'| xargs rm -rf[root@bogon ~]# find /mnt/ -name 'user'[root@bogon ~]# ls /mnt/dir1 file2.txt file4.doc file6.ppt file8.txt linux.txt test.shfile1.txt file3.txt file5.xls file7.txt file9.txt php.txt web.txt

标签:

相关文章

Java代码虚拟化保护技术与应用前景

软件应用的需求日益增长,软件开发过程中对代码的保护成为了一个重要议题。Java作为一种广泛应用于企业级应用的编程语言,其代码虚拟化...

PHP教程 2025-03-02 阅读1 评论0

CAD插件错误代码与应对步骤

CAD(计算机辅助设计)软件在工程设计领域得到了广泛应用。CAD插件作为提升设计效率的重要工具,在提高设计师工作效率的也带来了一定...

PHP教程 2025-03-02 阅读1 评论0

上古卷轴代码规则大全游戏背后的编程奥秘

《上古卷轴》作为一款深受玩家喜爱的角色扮演游戏,自问世以来便以其丰富的世界观、独特的游戏体验和深厚的文化底蕴吸引了无数玩家。在这款...

PHP教程 2025-03-02 阅读1 评论0