Pipe which to cd

Joined
Jul 23, 2009
Messages
2
Reaction score
0
Points
1
I am trying to pipe the output from the which command to change directory with the following line of code

Code:
which ls | cd

I assumed this would change my current directory to where the ls command is located, i.e. /bin. I know in this case it is easier to type

Code:
cd /bin

but if the directory I want is 5 levels deep the piping method would be quicker. Thanks in advance.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top