I have had this function I use it very often and it works fine.
Here it is:
cdx () { cd `dirname $1` ; }
However, this does not work with spaces. When I use it like this for example
cdx ~/desktop/folder/file\ file
It returns
usage: dirname path
But what I am passing is, essentially dirname path. So what am I supposed to do to fix this? (It also does the same thing when there are spaces in a folder names)
My first thought was using quotes, like cdX "directory\ whatever" but it did not work either.