I'm trying to navigate to the directory in which a file resides. i.e. I'm trying to
cd $(which chromedriver)
That errors for obvious reasons cd: not a directory: /usr/local/bin/chromedriver
Is there either
An alternative to
cdthat navigates to the directory of a file, orA way to handle or parse the output of
whichso that it's generalisable (i.e. not just removing the last 10 characters in the case ofchromedriver, but which works for all applications)
cd $(dirname $(which chromedriver))– Quora Feans Aug 05 '20 at 04:32cd "$(dirname "$FILEPATH")"– Kamil Maciorowski Aug 05 '20 at 04:33