為了寫作業用到的
參考 linux - Exclude directory …

為了寫作業用到的
參考 linux - Exclude directory from find . command - Stack Overflow

基本上就是

$ find $target_path -path $exclude_path -prune -o [condition] -print  

我自己的用法是

$ find / -path /proc -prune -o -perm o=w -type f -print  

用來 print 出整個 / 底下除了 /proc 以外所有的 global writable 的 file


解答中甚至給出了要排除多個資料夾路徑的寫法

find $target_path -type d \( -path $exclude_path1 -o -path $exclude_path2 -o -path $exclude_path3 \) -prune -o -print  

Appendix

  • -prune
    • This primary always evaluates to true. It causes find to not descend into the current file. Note, the -prune primary has no effect if the -d option was specified.

Share


Donation

如果覺得這篇文章對你有幫助, 除了留言讓我知道外, 或許也可以考慮請我喝杯咖啡, 不論金額多寡我都會非常感激且能鼓勵我繼續寫出對你有幫助的文章。

If this blog post happens to be helpful to you, besides of leaving a reply, you may consider buy me a cup of coffee to support me. It would help me write more articles helpful to you in the future and I would really appreciate it.


Related Posts