Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 Mar 24 '13 at 15:03

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

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


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