简体   繁体   中英

Unable to use “-prune” option from find command

I don't want to find "passwd" under "/etc" directory, but I do want to find rest of the "passwd", I am trying following,

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

this is the output I get,

/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

this is the output I expect,

/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

尝试这个:

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

尝试-path而不是-name

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM