Find 的使用
文件查找
find .(當(dāng)前目錄) -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 . -path"./aa " -prune -o -name ".txt" -print
find . -path"./aa " -prune -o -path "./bb" -prune -o -name "*.txt" -print
權(quán)限查找
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
按照時(shí)間查找
兩天之內(nèi)被改過的
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
執(zhí)行命令
find . -name "1.txt" -ok rm {} ; 新建 touch 12a.txt
find . -name "12a.txt" -exec cp {}{}.bak ;
grep 匹配
cat 1.txt | grep all --color只要出現(xiàn)all cat 1.txt | grep -w "all" 匹配單詞
cat -n
取反
cat 1.txt | grep -v -w "all"
統(tǒng)計(jì)次數(shù)
cat 1.txt | grep -c "all"
顯示行數(shù)
grep -n "all"
顯示匹配的文件
grep "all"1.txt 2.txt 3.txt
grep -l "all"1.txt 2.txt 3.txt 只顯示匹配出來的文件名
grep -i "ALL" *.txt 不區(qū)分大小寫的匹配
系統(tǒng)服務(wù)管理
chkconfig --list 顯示當(dāng)前運(yùn)行的所有服務(wù)
/etc/inittab
netstat -antl all n端口 t tcp協(xié)議 l listen狀態(tài)
chkconfig --add httpd 增加服務(wù)
chkconfig --del httpd 刪除
chkconfig --level 12345
轉(zhuǎn)載自:http://www.cnblogs.com/ke-wu/p/5759170.html