1

How would I list all directories containing the program name "minecraft"?

3
  • What have you tried so far?
    – roaima
    Oct 18 '19 at 21:12
  • 1
    Programs called minecraft, or any files called minecraft? Directories in your PATH or any directory on the system?
    – roaima
    Oct 18 '19 at 21:14
  • Do you want to find directories whose name contains minecraft or directories whose contents include a file whose name includes minecraft?
    – jesse_b
    Oct 18 '19 at 21:42
1

If this is Unix, you could type "which Minecraft". If it is Windows, you could type ""where Minecraft". Add --all to the which command to list all the programs not just the first. Both programs search the PATH or in the case of Windows, the path plus certain runtime registry locations.

To find programs in places beyond the path, do the find command above, but add --perm to specify the an executable. Add --type f to limit it to files. In ancient days, there used to be an slocate command which searches an index.

1

Using find and dirname to locate all files with the name minecraft in the current directory (adjust the search location to suit).

find . -type f -name minecraft | xargs -L 1 dirname

For finding files with executable permissions, you can use the -perm option for find (adjust the value to suit your search criteria):

find . -type f -perm +0111 -name minecraft | xargs -L 1 dirname

This should print the directory path relative to the search location.

If you want to search your whole system, just pass / as the first argument to find.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.