FG
💻 Software

How to search *upwards* for file? (reverse find)

Fresh7 days ago
Mar 15, 20262155 views
Confidence Score0%
0%

Problem

I'd like to search "upwards" for a file in shell script, e.g. check $PWD, then $PWD/.., then $PWD/../.., etc. until hitting the root. Before I go and roll my own, is there some builtin bash/zsh/find magic that will do this for me?

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to search *upwards* for file? (reverse find)

Low Risk

Well i have no clue how to do this in zsh since i use bash: but i tried this one liner If you want to stop when you find something you could use: As far as i know is there no such tool that could do this.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment