Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # go into dir with a specific file in the subdirectory
- function cdf() {
- f=$(dirname $(find . -iname "*$1*" -type f -print -quit 2>/dev/null | head -1) 2>/dev/null)
- if [ -z "$f" ]; then
- echo #'not found'
- else
- #echo "found in:" $f
- cd $f
- fi
- }
- # go into a specific dir anywhere below this
- function cdd() {
- d=$(find . -iname "*$1*" -type d -print -quit 2>/dev/null | head -1)
- if [ -z "$d" ]; then
- echo #'not found'
- else
- cd $d
- fi
- }
- # go into dir with a specific file in the subdirectory. Uses regex and substitues . with .*
- function cdfr() {
- pat=$1
- pat=${pat//./.*}
- f=$(dirname $(find . -regex ".*$pat.*" -type f -print -quit 2>/dev/null | head -1) 2>/dev/null)
- if [ -z "$f" ]; then
- echo #'not found'
- else
- #echo "found in:" $f
- cd $f
- fi
- }
- # go into a specific dir anywhere below this. Uses regex and substitues . with .*
- function cddr() {
- #replace in between "."s with .*
- pat=$1
- pat=${pat//./.*}
- #echo $pat
- d=$(find . -regex ".*$pat.*" -type d -print -quit 2>/dev/null | head -1)
- if [ -z "$d" ]; then
- echo #'not found'
- else
- cd $d
- fi
- }
Add Comment
Please, Sign In to add comment