找到非隐藏目录

时间:2014-12-12 14:41:03

标签: bash terminal

我有这个命令

$ find -path './nas/cdn/catalog/[^.]*' -prune -type d
./nas/cdn/catalog/swatches
./nas/cdn/catalog/product_shots
./nas/cdn/catalog/full_length
./nas/cdn/catalog/cropped
./nas/cdn/catalog/drawings

但这不会返回所有目录

$ find -path './nas/cdn/catalog/*' -type d
./nas/cdn/catalog/swatches
./nas/cdn/catalog/swatches/.AppleDouble
./nas/cdn/catalog/.AppleDouble
./nas/cdn/catalog/product_shots
./nas/cdn/catalog/product_shots/.AppleDouble
./nas/cdn/catalog/product_shots/high_res
./nas/cdn/catalog/product_shots/high_res/.AppleDouble
./nas/cdn/catalog/product_shots/high_res/back
./nas/cdn/catalog/product_shots/high_res/back/.AppleDouble
./nas/cdn/catalog/product_shots/high_res/front
./nas/cdn/catalog/product_shots/high_res/front/.AppleDouble
./nas/cdn/catalog/product_shots/low_res
./nas/cdn/catalog/product_shots/low_res/.AppleDouble
./nas/cdn/catalog/product_shots/low_res/back
./nas/cdn/catalog/product_shots/low_res/back/.AppleDouble
./nas/cdn/catalog/product_shots/low_res/front
./nas/cdn/catalog/product_shots/low_res/front/.AppleDouble
./nas/cdn/catalog/product_shots/thumbs
./nas/cdn/catalog/product_shots/thumbs/.AppleDouble
./nas/cdn/catalog/full_length
./nas/cdn/catalog/full_length/.AppleDouble
./nas/cdn/catalog/full_length/high_res
./nas/cdn/catalog/full_length/low_res
./nas/cdn/catalog/cropped
./nas/cdn/catalog/cropped/.AppleDouble
./nas/cdn/catalog/drawings
./nas/cdn/catalog/drawings/.AppleDouble

基本上我想从find命令

中删除所有.AppleDouble和其他.hidden目录

1 个答案:

答案 0 :(得分:0)

您可以使用-regex选项:

find . -type d -regex '\./nas/cdn/catalog/[^.]*'

[^.]*模式将确保不选择任何以DOT开头的条目。