Skip to content

Instantly share code, notes, and snippets.

@PerArneng
Created October 9, 2014 07:16
Show Gist options
  • Save PerArneng/13e90e0a7bdc2f6e8172 to your computer and use it in GitHub Desktop.
Save PerArneng/13e90e0a7bdc2f6e8172 to your computer and use it in GitHub Desktop.
A Bash function to find a directory and `cd` in to the first match. It works with wildcards `*` and `?`
function cdf() { cd `find . -type d -name "$1" | head -n1`; }
@PerArneng
Copy link
Author

Testcase:

$ mkdir -p foo/bar
$ cdf bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment