Last active
April 27, 2022 07:39
-
-
Save icetan/711ed132fbff05d371c93b8d4d11f1cd to your computer and use it in GitHub Desktop.
A bash to traverse a path upwards to find a certain file or directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rtrav() { [ -e "$2/$1" ] && echo "$2" || { [ "$2" != / ] && rtrav "$1" "$(dirname "$2")"; }; } | |
# Find node_modules directory | |
rtrav node_modules $PWD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment