Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I need to devise a single find command that searches for:

  • All C# or Java programs
  • Located in the home directory of the current user
  • Have at least one hard link
  • Readable for everybody
  • Have at least one write bit set
  • Not executable for anybody

I have come up with answers for everything except the last criterion and here's my code:

find /home -name "*.c" "*.java" -links 1 (-perm -a=r -a -perm -a=!x)

I don't really think it's right and it is incomplete. Help?

share|improve this question

migrated from stackoverflow.com Mar 24 '13 at 15:03

This question came from our site for professional and enthusiast programmers.

1 Answer 1

find $HOME \(-name '*.java -o -name '*.c' \) \    # home directory && filenames
      -link +0                               \    # one or more hard links
      ! -perm -111                           \    # not executable by anybody  -111 means "any of" 
       -perm /444                            \    # at least one write bit set
       -perm 666                                 # ugo read

You can smash this back together into one longer, harder to read line. I broke it out to make it readable.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.