码迷,mamicode.com
首页 > 其他好文 > 详细

find

时间:2018-07-09 12:35:31      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:httpd   tab   bbb   perm   删除   init   rem   path   大小写   

Find 的使用
文件查找
find .(当前目录) -name 
find . -name "*.txt" -print
find . -name ‘[A-Z,a-z,1-100]*‘.txt -print
find . -name "1.txt" -prune -o -name "*.txt" -print

在当前目录下搜索指定文件:

find . -name test.txt

在当前目录下模糊搜索文件:

find . -name ‘*.txt‘

目录查找
find . -path"./aa " -prune -o -name "*.txt" -print
find . -path"./aa " -prune -o -path "./bb" -prune -o -name "*.txt" -print

权限查找
find . -prem 775 -print
不查找aaa下的文件   find . -path "./aa" -prune -0 -perm 775 -print
find . -path "./aa" -prune -0 -path "./bb" -prune -o -perm 775 -print
find . \( -path "./aaa" -o -path "./bbb" \) -prune -o -perm 775 -print

按类型查找
软连接  可以理解为快捷方式
ln -s ./aaa/* ./ddd
find .-type l -print

按属主查找
find / -user www -type f -print
查找属主被删除
find / -nouser -type f -print

find / -group apache -type -f -print

按照时间查找
两天之内被改过的
find .-mtime -2 -type f -print
两天之前被改过的
find .-mtime +2 -type f -print
十分钟之前被改过的
find . -cmin +10 -type f -print

按照文件新旧查找

查找比aa.txt新的文件
find . -newer "aa.txt" -type f -print
查找比aa.txt旧的文件
find . ! -newer "aa.txt" -type f -print
查找比aa.txt新的比bb.txt旧的文件
find . -newer “aa.txt”! -newer“bb.txt" -type f -print

按照文件大小查找
在根目录小大于1M的
find / -size +1M -type -print
小于1M的文件
find / -size -1M -type -print
执行命令
find . -name "1.txt" -ok rm {} \;                   新建  touch 12a.txt
find . -name "12a.txt" -exec cp {}{}.bak \;

grep 匹配
cat 1.txt | grep all --color只要出现all   cat 1.txt | grep -w "all" 匹配单词
cat -n 
取反
 cat 1.txt | grep -v -w "all" 
统计次数
 cat 1.txt | grep -c "all"
显示行数
grep -n "all"
显示匹配的文件
grep "all"1.txt 2.txt 3.txt
grep -l "all"1.txt 2.txt 3.txt 只显示匹配出来的文件名

grep -i "ALL" *.txt  不区分大小写的匹配

系统服务管理

chkconfig --list   显示当前运行的所有服务
/etc/inittab
netstat -antl   all n端口 t tcp协议 l listen状态
chkconfig --add httpd 增加服务
chkconfig --del httpd 删除
chkconfig --level 12345

find

标签:httpd   tab   bbb   perm   删除   init   rem   path   大小写   

原文地址:https://www.cnblogs.com/debruyne/p/9283012.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!