[Linux] 只針對檔案或只針對目錄做遞迴chmod

以前只會這樣

可是這樣會連帶目錄+檔案都變成775,這不是我要的啊~~ 我要目錄755檔案644這樣啊,難道我要一個一個去弄嗎,這樣超級蠢的說…

後來估狗了一下,果然很多人跟在下一樣有同樣的困擾,也同樣有很多大神提供了解決辦法,那就是神奇的find指令啦~~

針對當前目錄下的所有目錄做遞迴chmod

針對當前目錄下的所有檔案做遞迴chmod

神奇的關鍵就是那個-type了,d表示目錄,f表示檔案,找出來之後用管線命令轉向給xargs指令去處理,xargs幫我們把標準輸出抓進來丟給chmod去執行,這樣就完成囉,喔耶~~(轉圈)(灑花)

在〈[Linux] 只針對檔案或只針對目錄做遞迴chmod〉中有 4 則留言

  1. My partner and I stumbled over here by a different page and thought I might
    as well check things out. I like what I see so now i am following you.
    Look forward to going over your web page again.

    回覆
  2. Woah! I’m really loving the template/theme of this blog. It’s simple, yet effective.

    A lot of times it’s hard to get that “perfect balance” between superb usability and visual appearance. I must say that you’ve done a excellent job with this.
    Additionally, the blog loads very fast for me on Firefox.
    Excellent Blog!

    回覆

發佈留言