I often need to find a file, then cd to its directory. This command will do both, provide that the file’s name is unique enough:
$ cd $(dirname $(find ~ -name emails.txt))
Please note that the above command works for bash shell, but not csh: csh’s equivalent to the $( … ) construct is the ` … ` construct which the bash shell also understands. However, the “ construct does not allow for nesting.
