Reputation: 94
I would like to use a command that change the current working directory to the one i find out using the "find" command.Is there any way that I can do that on a single line in bash?
I would like to use a command that change the current working directory to the one i find out using the find
command.Is there any way that I can do that on a single line in bash?
I want to go to a directory called "mydir".I only know that it is somewhere in "documents". I want to change my current working directory to "mydir".
I know that I can know the path using find -name mydir
.
Upvotes: 0
Views: 305
Reputation: 67567
this should do..
$ cd "$(find . -type d -name myDir -print -quit)"
-quit
to ensure at most one value is returned (and finish looking after first match), may not be supported in all find
s. Otherwise you need to filter the result but will take longer.
Upvotes: 3