Help with this script

Robert Hartman rhartman at thestepchild.sgi.com
Wed Apr 10 12:42:44 AEST 1991


In article <1991Apr9.175008.12044 at leland.Stanford.EDU> rgupta at leland.Stanford.EDU (Rajesh Gupta) writes:
>
>How about:
>
>	cd `find . -name <argument> -type d -print` 

Ooooh!  I like this!  Just cooked a version for csh:

alias jd  'set arg="\!:1"; cd `(find . -name "*${arg}*" -type d -print) \
    | head -1`' # jump to a directory

You have to use a variable to capture the alias argument, because the
history (argument) substitution syntax collides with the trailing *
in the argument to -name.  I want to go to the first match, so the head
command is necessary to avoid "Ambiguous" errors.  I have "," aliased to
pop me back to the previous directory if find guesses wrong.

-r



More information about the Comp.unix.shell mailing list