1

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

Community
  • 1
  • 1
Yogesh
  • 214
  • 1
  • 7

2 Answers2

2

Try this:

 find / -path '/etc' -prune -o -name 'passwd' -print
Mithrandir
  • 24,869
  • 6
  • 50
  • 66
0

try -path instead of -name

sudo find / -path /etc -prune -o -name 'passwd' -print 
SMA
  • 36,381
  • 8
  • 49
  • 73