I want to find a directory using grep then change current directory to the resulting directory.
For example:
$ ls | grep 1670 |
finds me directory haib12CJS1670. I am trying to do something like below:
$ ls | grep 1670 | cd
so that my directory is set to haib12CJS1670 at a single step. Obviously my way is not working. Any suggestions? Thank you
should get your
cdto work (note, those are “back-ticks”)An alternative approach (some would say preferred) would be to use the
$substitution. E.g.,though I can’t get this to work with the
tcsh, it works fine withbash.The first solution is shell-agnostic 🙂