I'm trying to write an alias which will jump to the descendant directory of cwd which contains a specified file (or the first find found occurrence of such a filename):

The following command combination achieves the desired result:

cd `dirname \`find -name 'MyFile.txt' | sed -n 1p\``

However, I can't seem to escape this in the correct way to create a working alias:

alias jump="cd \`dirname \\\`find -name '$1' | sed -n 1p\\\`\`"

Output:

/*
dirname: missing operand
Try `dirname --help' for more information.
bash: cd: find: No such file or directory

My logic is that backticks need escaping in a double quoted string with a single \ and I can't do \\ gets translated to a single backslash within a string, so the second nested backtick requires 1+2=3.

Any suggestions?

Edit
Report