Answer
Since there's a zsh one-liner here's a more general unix oneish-liner to search the 3 parent directories:
$ name=fileOrDirName
$ eval find ./$(printf "{$(echo %{1..4}q,)}" | sed 's/ /\.\.\//g')/ -maxdepth 1 -name $name
Explanation
I'll admit it's not the prettiest command, but it's one line. To search 4 directories up replace echo %{1..4}q,
with echo %{1..5}q,
. Specify the file or directory's name with the name variable.
In short $(printf ... | sed ...)
is substituted for its output using command substitution which is then expanded with find
using brace expansion. Broken into two commands it looks like this (with a copy and paste in the middle):
$ printf "{$(echo %{1..4}q,)}" | sed 's/ /\.\.\//g'
{'',../'',../../'',../../../'',}
$ #copy and paste the output
$ find ./{'',../'',../../'',../../../'',} -maxdepth 1 -name $name
You can learn more about shell expansions with man bash
or in the resources below on the gnu website