龙空技术网

shell文本操作-find查找命令

科技yuan 359

前言:

今天咱们对“php查找txt”都比较讲究,兄弟们都需要学习一些“php查找txt”的相关资讯。那么小编同时在网络上网罗了一些关于“php查找txt””的相关资讯,希望你们能喜欢,看官们一起来学习一下吧!

find . -name "*.txt"-在当前目录下找以txt结尾的文件

示例:

[root@bogon mnt]# find . -name '*.txt'找到所有包含txt的文件./file3.txt./file2.txt./file1.txt./user.txt
find . -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.txt
find / -name "host*"在根目录下找以host开头的文件

示例:

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

[root@bogon mnt]# find / -name ifcfg-eth0/etc/sysconfig/network-scripts/ifcfg-eth0
find . -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.txt
find -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.txt
find /etc -mtime -1在/etc下找更改时间在1天以内的文件

示例:

[root@bogon ~]# find /etc -mtime -1|wc -l11
find /etc -mtime +1在/etc下找更改时间在1天以前的文件

示例:

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

示例:

[root@bogon ~]# find /etc -type d|wc -l128[root@bogon ~]# find /etc -type l|wc -l195
find . -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.txt
find . -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

标签: #php查找txt