Open Source Tips
Sunday, April 21, 2013
BASH Change Dir to Location of File
How do you get to the directory that a file is located in?
Happily, the file I was interested in was a command so the following worked:
cd $(which brew | xargs dirname)
When the needed file is not a command, using FIND works but is slower:
cd $(find . -name hbase-0.90.5.tar.gz 2> /dev/null | xargs dirname)
Newer Post
Older Post
Home