如何search主目录中的目录?

我想查找主目录中的所有点目录

find ~/ -name .* -Olevel 1 

但它不能工作

问题是你的shell正在扩展.* 。 你想引用它,即'.*' ,以便find它的交易,而不是你的shell。

例如,要查找您的主目录中的所有目录,

 find ~ -maxdepth 1 -type d -name '.*' 

在我的系统上,这产生了:

 /root/.config /root/.java /root/.cache /root/.aptitude /root/.gnupg /root/.grails /root/.dbus /root/.ssh 

您可以使用

 find ~/ -maxdepth 1 -name '.*' -type -d 

你必须停止shell扩展.*通过放在周围,然后find然后展开'.*'正确。 要仅查找目录,请使用-d开关并将查找限制在~/目录中。- -maxdepth 1