find tar 壓縮第一層目錄,用於資料備份。

來源:互聯網
上載者:User

標籤:

find *.tar.gz -exec tar zxvf ‘{}‘ \;
//尋找目前的目錄下的.tar.gz 的檔案的 並發送給後面的命令執行
find . -maxdepth 1
//尋找目前的目錄下的檔案並顯示出來。
find . -maxdepth 1 -type d
//尋找目前的目錄下的檔案

find . -maxdepth 1 -type d -exec cp -r ‘{}‘ /home/android/autonavi-project/ ‘;‘
//尋找目前的目錄 並拷貝到某個位置

find . -maxdepth 1 -type d -exec tar zcvf ‘{}‘.tar.gz ‘{}‘ ‘;‘
//對目前的目錄壓縮後放到目前的目錄。
// -maxdepth 0表示先顯示現在的目錄再顯示其他的。
find . -maxdepth 1 -type d -exec tar zcvf /test2/‘{}‘.tar.gz ‘{}‘ ‘;‘
//對目前的目錄壓縮後放到指定(/test2/)。

find /test -path /test/a -prune -o -name "*" -print
//尋找test目錄下,顯示除了a檔案夾之外的檔案


find /test2 -path /test2/a.tar.gz -prune -o -name "*" -print
//尋找test2目錄下的除了 a.tar.gz 的所有的檔案和目錄。

find /test2 -path /test2/..tar.gz -prune -o -name "*.tar.gz" -exec tar zxvf ‘{}‘ \;
//尋找test2目錄下的除了..tar.gz 的所有.tar.gz的進行解壓。

find /test2 -path /test2/. -prune -o -name "*" -exec tar zcvf ‘{}‘.tar.gz ‘{}‘ \;
//尋找test2目錄下的除了.這個目錄外的所有目錄進行壓縮。


//本檔案的終極目標,一個目錄下的目錄進行壓縮。不對目前的目錄進行壓縮。並且不對OUT檔案進行壓縮。
find . -mindepth 1 -maxdepth 1 -path "./out" -prune -o -type d -exec tar zcvf ‘{}‘.tar.gz ‘{}‘ ‘;‘
//

find tar 壓縮第一層目錄,用於資料備份。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.