I'd like to find a way to find a given file by looking upward in the directory structure, rather than recursively searching through child directories.
There's a node module that appears to do exactly what I want, but I don't want to depend on installing JavaScript or packages like that. Is there a shell command for this? A way to make find
do that? Or a standard approach that I just wasn't able to find through Googling?
Best Answer
This is a direct translation of the find-config algorithm in generic shell commands (tested under bash, ksh, and zsh), where I use a return code of 0 to mean success and 1 to mean NULL/failure.
Sample run, with the setup
stolencopied and extended from Stephen Harris's answer: