The which function returns the full path to some other function, if I'm not mistaken.$ which ls   # => /bin/lsBut if I wanted to the directory the function is in, how would I do that? I'm thinking of doing something like this:$ cd $(which ls)Obviously, that won't work because ls isn't a directory. Perhaps I'm barking up the wrong tree with which?
Would like to change directory to the result of which function
cd command;which
This will do the job:$ cd $(dirname $(which ls))From man dirname:dirname - strip last component from file name