find命令詳解(下)

來源:互聯網
上載者:User

文章編輯整理自:http://icarusli.iteye.com/blog/646424

五、find命令執行個體1、尋找目前使用者主目錄下的所有檔案:下面兩種方法都可以使用find $HOME -print或find ~ -print2、讓目前的目錄中檔案屬主具有讀、寫入權限,並且檔案所屬組的使用者和其他使用者具有讀許可權的檔案;find . -type f -perm 644 -exec ls -l {  } \;3、為了尋找系統中所有檔案長度為0的普通檔案,並列出它們的完整路徑;find / -type f -size 0 -exec ls -l {} \;4、尋找/var/logs目錄中更改時間在7日以前的普通檔案,並在刪除之前詢問它們;find /var/logs -type f -mtime +7 -ok rm {} \;5、為了尋找系統中所有屬於root組的檔案;find . -group root -exec ls -l {  } \;結果:-rw-r--r--    1 root     root          595 10月 31 01:09 ./fie16、find命令將刪除當目錄中訪問時間在7日以來、含有數字尾碼的admin.log檔案。該命令只檢查三位元字,所以相應檔案的尾碼不要超過999。先建幾個admin.log*的檔案 ,才能使用下面這個命令find . -name "admin.log[0-9][0-9][0-9]" -atime -7  -okrm {  } \;< rm ... ./admin.log001 > ? n< rm ... ./admin.log002 > ? n< rm ... ./admin.log042 > ? n< rm ... ./admin.log942 > ? n7、為了尋找當前檔案系統中的所有目錄並排序;find . -type d | sort8、為了尋找系統中所有的rmt磁帶裝置;find /dev/rmt -print9、尋找包含特定字串的檔案在目前的目錄尋找所有包含特定字串AsyncTask的java檔案find . -name "*.java" | xargs grep 'AsyncTask'

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.