2014-10-17 49 views
1

我不想在「/ etc」目錄下找到「passwd」,但我確實希望找到其餘的「passwd」,我正在嘗試跟蹤,無法使用查找命令中的「-prune」選項

sudo find/-name '/etc' -prune -o -name 'passwd' -print 

這是輸出我得到的,

/home/previous_cache/1_0_59/httpd-2.4.7/srclib/apr/passwd 
/home/1_0_59/httpd-2.4.7/srclib/apr/passwd 
/etc/pam.d/passwd 
/etc/passwd 
/etc/cron.daily/passwd 
/usr/share/bash-completion/completions/passwd 
/usr/share/lintian/overrides/passwd 
/usr/share/doc/passwd 
/usr/bin/passwd 

這是我所期望的輸出,

/home/previous_cache/1_0_59/httpd-2.4.7/srclib/apr/passwd 
/home/1_0_59/httpd-2.4.7/srclib/apr/passwd 
/usr/share/bash-completion/completions/passwd 
/usr/share/lintian/overrides/passwd 
/usr/share/doc/passwd 
/usr/bin/passwd 

I referred this, good info about prune, but could not solve my problem

回答

2

試試這個:

find/-path '/etc' -prune -o -name 'passwd' -print 
0

嘗試的-path代替-name

sudo find/-path /etc -prune -o -name 'passwd' -print