9久久伊人精品综合,亚洲一区精品视频在线,成 人免费va视频,国产一区二区三区黄网,99国产精品永久免费视频,亚洲毛片多多影院,精品久久久无码人妻中文字幕,无码国产欧美一区二区三区不卡
學習啦 > 學習電腦 > 操作系統 > Linux教程 >

linux中的find命令有哪些用法參數設置是什么

時間: 加城1195 分享

  Linux中的find命令主要用于各種查找,很常用,其中包括了很多的參數選項,那么具體參數有什么呢?怎么用?下面由學習啦小編為大家整理了linux中的find命令參數的相關知識,希望對大家有幫助!

  linux中的find命令詳解

  一.find命令

  基本格式:find path expression

  1.按照文件名查找

  (1)find / -name httpd.conf  #在根目錄下查找文件httpd.conf,表示在整個硬盤查找

  (2)find /etc -name httpd.conf  #在/etc目錄下文件httpd.conf

  (3)find /etc -name '*srm*'  #使用通配符*(0或者任意多個)。表示在/etc目錄下查找文件名中含有字符串‘srm’的文件

  (4)find . -name 'srm*'   #表示當前目錄下查找文件名開頭是字符串‘srm’的文件

  2.按照文件特征查找

  (1)find / -amin -10   # 查找在系統中最后10分鐘訪問的文件(access time)

  (2)find / -atime -2   # 查找在系統中最后48小時訪問的文件

  (3)find / -empty   # 查找在系統中為空的文件或者文件夾

  (4)find / -group cat   # 查找在系統中屬于 group為cat的文件

  (5)find / -mmin -5   # 查找在系統中最后5分鐘里修改過的文件(modify time)

  (6)find / -mtime -1   #查找在系統中最后24小時里修改過的文件

  (7)find / -user fred   #查找在系統中屬于fred這個用戶的文件

  (8)find / -size +10000c  #查找出大于10000000字節的文件(c:字節,w:雙字,k:KB,M:MB,G:GB)

  (9)find / -size -1000k   #查找出小于1000KB的文件

  3.使用混合查找方式查找文件

  參數有: !,-and(-a),-or(-o)。

  (1)find /tmp -size +10000c -and -mtime +2   #在/tmp目錄下查找大于10000字節并在最后2分鐘內修改的文件

  (2)find / -user fred -or -user george   #在/目錄下查找用戶是fred或者george的文件文件

  (3)find /tmp ! -user panda  #在/tmp目錄中查找所有不屬于panda用戶的文件

  find命令參數1.使用name選項

  文件名選項是find命令最常用的選項,要么單獨使用該選項,要么和其他選項一起使用。 可以使用某種文件名模式來匹配文件,記住要用引號將文件名模式引起來。 不管當前路徑是什么,如果想要在自己的根目錄$HOME中查找文件名符合*.log的文件,使用~作為 'pathname'參數,波浪號~代表了你的$HOME目錄。

  find ~ -name "*.log" -print

  想要在當前目錄及子目錄中查找所有的‘ *.log‘文件,可以用:

  find . -name "*.log" -print

  想要的當前目錄及子目錄中查找文件名以一個大寫字母開頭的文件,可以用:

  find . -name "[A-Z]*" -print

  想要在/etc目錄中查找文件名以host開頭的文件,可以用:

  find /etc -name "host*" -print

  想要查找$HOME目錄中的文件,可以用:

  find ~ -name "*" -print 或find . -print

  要想讓系統高負荷運行,就從根目錄開始查找所有的文件。

  find / -name "*" -print

  如果想在當前目錄查找文件名以一個個小寫字母開頭,最后是4到9加上.log結束的文件:

  命令:

  find . -name "[a-z]*[4-9].log" -print

  輸出:

  [root@localhost test]# ll

  總計 316

  -rw-r--r-- 1 root root 302108 11-13 06:03 log2012.log

  -rw-r--r-- 1 root root 61 11-13 06:03 log2013.log

  -rw-r--r-- 1 root root 0 11-13 06:03 log2014.log

  -rw-r--r-- 1 root root 0 11-13 06:06 log2015.log

  drwxr-xr-x 6 root root 4096 10-27 01:58 scf

  drwxrwxr-x 2 root root 4096 11-13 06:08 test3

  drwxrwxr-x 2 root root 4096 11-13 05:50 test4

  [root@localhost test]# find . -name "[a-z]*[4-9].log" -print

  ./log2014.log

  ./log2015.log

  ./test4/log2014.log

  [root@localhost test]#

  find命令參數2.用perm選項

  按照文件權限模式用-perm選項,按文件權限模式來查找文件的話。最好使用八進制的權限表示法。

  如在當前目錄下查找文件權限位為755的文件,即文件屬主可以讀、寫、執行,其他用戶可以讀、執行的文件,可以用:

  [root@localhost test]# find . -perm 755 -print

  .

  ./scf

  ./scf/lib

  ./scf/service

  ./scf/service/deploy

  ./scf/service/deploy/product

  ./scf/service/deploy/info

  ./scf/doc

  ./scf/bin

  [root@localhost test]#

  還有一種表達方法:在八進制數字前面要加一個橫杠-,表示都匹配,如-007就相當于777,-005相當于555,

  命令:

  find . -perm -005

  輸出:

  [root@localhost test]# ll

  總計 316

  -rw-r--r-- 1 root root 302108 11-13 06:03 log2012.log

  -rw-r--r-- 1 root root 61 11-13 06:03 log2013.log

  -rw-r--r-- 1 root root 0 11-13 06:03 log2014.log

  -rw-r--r-- 1 root root 0 11-13 06:06 log2015.log

  drwxr-xr-x 6 root root 4096 10-27 01:58 scf

  drwxrwxr-x 2 root root 4096 11-13 06:08 test3

  drwxrwxr-x 2 root root 4096 11-13 05:50 test4

  [root@localhost test]# find . -perm -005

  .

  ./test4

  ./scf

  ./scf/lib

  ./scf/service

  ./scf/service/deploy

  ./scf/service/deploy/product

  ./scf/service/deploy/info

  ./scf/doc

  ./scf/bin

  ./test3

  [root@localhost test]#

  find命令參數3.忽略某個目錄

  如果在查找文件時希望忽略某個目錄,因為你知道那個目錄中沒有你所要查找的文件,那么可以使用-prune選項來指出需要忽略的目錄。在使用-prune選項時要當心,因為如果你同時使用了-depth選項,那么-prune選項就會被find命令忽略。如果希望在test目錄下查找文件,但不希望在test/test3目錄下查找,可以用:

  命令:

  find test -path "test/test3" -prune -o -print

  輸出:

  [root@localhost soft]# find test -path "test/test3" -prune -o -print

  test

  test/log2014.log

  test/log2015.log

  test/test4

  test/test4/log2014.log

  test/test4/log2013.log

  test/test4/log2012.log

  test/scf

  test/scf/lib

  test/scf/service

  test/scf/service/deploy

  test/scf/service/deploy/product

  test/scf/service/deploy/info

  test/scf/doc

  test/scf/bin

  test/log2013.log

  test/log2012.log

  [root@localhost soft]#

  find命令參數4.使用find查找文件的時候怎么避開某個文件目錄

  實例1:在test 目錄下查找不在test4子目錄之內的所有文件

  命令:

  find test -path "test/test4" -prune -o -print

  輸出:

  [root@localhost soft]# find test

  test

  test/log2014.log

  test/log2015.log

  test/test4

  test/test4/log2014.log

  test/test4/log2013.log

  test/test4/log2012.log

  test/scf

  test/scf/lib

  test/scf/service

  test/scf/service/deploy

  test/scf/service/deploy/product

  test/scf/service/deploy/info

  test/scf/doc

  test/scf/bin

  test/log2013.log

  test/log2012.log

  test/test3

  [root@localhost soft]# find test -path "test/test4" -prune -o -print

  test

  test/log2014.log

  test/log2015.log

  test/scf

  test/scf/lib

  test/scf/service

  test/scf/service/deploy

  test/scf/service/deploy/product

  test/scf/service/deploy/info

  test/scf/doc

  test/scf/bin

  test/log2013.log

  test/log2012.log

  test/test3

  [root@localhost soft]#

3996221 主站蜘蛛池模板: 亚洲免费成人av一区| 亚洲精品天堂在线观看| 亚洲人妻一区二区精品| 性动态图无遮挡试看30秒| 国产精品自在线拍国产手机版| 亚洲中文久久久精品无码| 久久三级中文欧大战字幕| 无码日韩精品一区二区三区免费 | 国产国产乱老熟女视频网站97| 国产精品自拍视频免费看| 久久天堂综合亚洲伊人HD妓女| 1精品啪国产在线观看免费牛牛| 国产午夜福利视频合集| 一二三三免费观看视频| 精品一区二区三区不卡| 国产精品久久精品| 精品九九人人做人人爱| 夜夜添无码试看一区二区三区| 亚洲欧美日韩综合久久久| 久久人妻国产精品| 欧美不卡无线在线一二三区观| 人妻体内射精一区二区三四| 亚洲天堂在线免费| 成人午夜福利一区二区四区| 青青青视频免费一区二区 | 无码人妻人妻经典| 国产精品会所一区二区三区| 亚洲sm另类一区二区三区| 狠狠躁夜夜躁人人爽天天5| 99热精品毛片全部国产无缓冲| 熟女少妇精品一区二区| 欧美综合婷婷欧美综合五月 | 国产精品自产拍在线播放| 人妻精品动漫h无码| 青草成人精品视频在线看| 综合色在线| 成人免费A级毛片无码片2022 | 一本大道久久香蕉成人网| 少妇人妻偷人精品视蜜桃| 亚洲欧洲精品日韩av| 国产一级r片内射免费视频|