Created
May 18, 2020 20:56
-
-
Save emanuelduss/b731828a0b4370f1d48265324a9570f9 to your computer and use it in GitHub Desktop.
Shell function that can be used to jump up in the directory structure to the last directory containing the provided string
This file contains 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
cdf(){ | |
local path="$(pwd | rev | cut -d/ -f2- | rev | grep -o -E ".*$1[^/]*")" | |
echo cd -- "$path" | |
cd -- "$path" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
local variable 'path' can named 'last_path'