免费看欧美黑人毛片-免费看毛片网站-免费看毛片的网站-免费看久久-中文字幕日韩欧美-中文字幕日韩精品一区

您現(xiàn)在的位置:首頁 > IT認(rèn)證 > Linux認(rèn)證 >

Linuxfind命令用法小結(jié)


find是個(gè)使用頻率比較高的命令。常常用它在系統(tǒng)特定目錄下,查找具有某種特征「名字類型屬主權(quán)限等」的文件。

  find命令的格式: find  [-path ……] -options [-print -exec -ok] path:要查找的目錄路徑。

  ~ 表示$HOME目錄。 表示當(dāng)前目錄/ 表示根目錄-print :表示將結(jié)果輸出到標(biāo)準(zhǔn)輸出-exec :對(duì)匹配的文件執(zhí)行該參數(shù)所給出的shell命令。形式為 command  {} \; ,注意{}與\; 之間有空格-ok :與-exec作用相同,區(qū)別在于,在執(zhí)行命令之前,都會(huì)給出提示,讓用戶確認(rèn)是否執(zhí)行

  options常用的有下選項(xiàng):-name 按照名字查找-perm 安裝權(quán)限查找-prune 不再當(dāng)前指定的目錄下查找-user 文件屬主來查找-group 所屬組來查找-nogroup 查找無有效所屬組的文件-nouser 查找無有效屬主的文件-type 按照文件類型查找下面通過一些簡(jiǎn)單的例子來介紹下find的常規(guī)用法:

  1、按名字查找

  在當(dāng)前目錄及子目錄中,查找大寫字母開頭的txt文件

  view plain [root@localhost ~]# find . -name '[A-Z]*.txt' -print

  在/etc及其子目錄中,查找host開頭的文件

  view plain [root@localhost ~]# find /etc -name 'host*' -print

  在$HOME目錄及其子目錄中,查找所有文件

  view plain [root@localhost ~]# find ~ -name '*' -print在當(dāng)前目錄及子目錄中,查找不是out開頭的txt文件

  view plain [root@localhost .code]# find . -name "out*" -prune -o -name "*.txt" -print

  2、按目錄查找

  在當(dāng)前目錄除aa之外的子目錄內(nèi)搜索 txt文件

  view plain [root@localhost .code]# find . -path "./aa" -prune -o -name "*.txt" -print

  在當(dāng)前目錄及除aa和bb之外的子目錄中查找txt文件

  view plain [root@localhost .code]# find . \( -path "./aa" -o -path "./bb" \) -prune -o -name "*.txt" -print

  在當(dāng)前目錄,不再子目錄中,查找txt文件

  view plain [root@localhost .code]# find .  ! -name "." -type d -prune -o -type f -name "*.txt" -print 3、按權(quán)限查找

  在當(dāng)前目錄及子目錄中,查找屬主具有讀寫執(zhí)行,其他具有讀執(zhí)行權(quán)限的文件

  view plain [root@localhost ~]# find . -perm 755 -print

  4、按類型查找

  在當(dāng)前目錄及子目錄下,查找符號(hào)鏈接文件

  view plain [root@localhost .code]# find . -type l -print

  5、按屬主及屬組

  查找屬主是www的文件

  view plain [root@localhost .code]# find / -user www -type f -print

  查找屬主被刪除的文件view plain [root@localhost .code]# find /  -nouser -type f -print

  查找屬組mysql的文件

  view plain [root@localhost .code]# find /  -group mysql -type f  -print

  查找用戶組被刪掉的文件

  view plain [root@localhost .code]# find /  -nogroup -type f  -print

  6、按時(shí)間查找

  查找2天內(nèi)被更改過的文件

  view plain [root@localhost .code]# find . -mtime -2 -type f -print

  查找2天前被更改過的文件

  view plain [root@localhost .code]# find . -mtime +2 -type f -print

  查找一天內(nèi)被訪問的文件

  view plain [root@localhost .code]# find . -atime -1 -type f -print

  查找一天前被訪問的文件

  view plain [root@localhost .code]# find . -atime +1 -type f -print

  查找一天內(nèi)狀態(tài)被改變的文件

  view plain [root@localhost .code]# find . -ctime -1 -type f -print

  查找一天前狀態(tài)被改變的文件

  view plain [root@localhost .code]# find . -ctime +1 -type f -print

  查找10分鐘以前狀態(tài)被改變的文件view plain [root@localhost .code]# find . -cmin +10 -type f -print

  7、按文件新舊

  查找比aa.txt新的文件

  view plain [root@localhost .code]# find . -newer "aa.txt"  -type f -print

  查找比aa.txt舊的文件

  view plain [root@localhost .code]# find . ! -newer "aa.txt"  -type f -print

  查找比aa.txt新,比bb.txt舊的文件

  view plain [root@localhost .code]# find . -newer 'aa.txt' ! -newer 'bb.txt' -type f -print

  8、按大小查找

  查找超過1M的文件

  view plain [root@localhost .code]# find / -size +1M -type f -print

  查找等于6字節(jié)的文件

  view plain [root@localhost .code]# find . -size 6c -print

  查找小于32k的文件

  view plain [root@localhost .code]# find . -size -32k -print

  9、執(zhí)行命令

  查找del.txt并刪除,刪除前提示確認(rèn)

  view plain [root@localhost .code]# find . -name 'del.txt' -ok rm {} \;

  查找aa.txt 并備份為aa.txt.bak

  view plain [root@localhost .code]# find . -name 'aa.txt' -exec cp {} {}.bak \;

相關(guān)文章

無相關(guān)信息
更新時(shí)間2022-03-13 11:11:02【至頂部↑】
聯(lián)系我們 | 郵件: | 客服熱線電話:4008816886(QQ同號(hào)) | 

付款方式留言簿投訴中心網(wǎng)站糾錯(cuò)二維碼手機(jī)版

客服電話:




主站蜘蛛池模板: 挠60分钟美女腋窝视频| 托比·斯蒂芬斯| 动漫秀场| ca109| 夫妻的世界电影| 卫途轮胎| 秀人网 官网门户免费| 浙江卫视今日播出节目表| 韩国青草视频| 在线播放啄木乌丝袜秘书| 大班生字表| 欧美一级毛片免费看| 欧美变态sososo另类| 满天星的电影都有哪些| 电影儿媳| 欧美gv网站| 二丫的美好生活[年代]| 少年团时代成员| 王心凌照片| 即便是爸爸也想恋爱| 挠60分钟美女腋窝视频| 性的视频| 香港之夜在线观看免费观看| 陈学冬演过的电视剧有哪些| 驾驶证三力测试题库| 九龙城寨在线观看| 寡妇一级毛片免费看| 三太太电影| 小男孩王泓翔唱梨花颂| 屠夫小姐在线播放| 澳亚卫视| 明日战记| 晓彤| 荒野求生无马赛原版在哪里看| 安浦清子| 80后相声新人李丁个人简历| 金奎丽| 在线播放免费观看| xiee| 皮肤诊所| 个体工商户起名字大全免费|