我需要在一台服务器上找到所有的行星,我正在考虑使用以下命令:
find / type d -name https-* | uniq但同时,我需要忽略一些目录/文件。我一直在尝试使用!,但它并不总是有效的。我有这样的命令:
find / type d -name https-* ! -name https-admserv* ! -name conf_bk* ! -name alias* ! -name *db* ! -name ClassCache* | uniq我得忽略这一切。目录admserv、conf_bk、alias和tmp以及文件*.db*基本上需要找到以下内容:
/opt/mw/iplanet/https-daniel.com
/opt/https-daniel1.com
/apps/https-daniel2.com我只需要找到目录名。我怎么能忽略所有其他的东西?
发布于 2015-04-10 00:39:46
使用-prune防止递归到目录:
find / \( -type d \( -name 'https-admserv*' -o -name 'conf_bk*' -o -name 'alias*' -o -name 'tmp' \) -prune -o -type d -name 'https-*' -print没有必要忽略任何文件。您只选择https-*目录,因此其他所有内容都会被忽略。
而且没有必要向uniq输送管道,因为find从不生成重复的。
https://stackoverflow.com/questions/29551363
复制相似问题