I frequently have to do this. For example:
$ vim /etc/pam.d/sudo $ vim /etc/pam.d/sudo-i $ cd /etc/pam.d/ # Figure I should just go to the directory
Now, is there a way I could obtain the directory of the last argument when it's a file path? What I'm hoping for is something like this:
$ vim /etc/pam.d/sudo $ vim /etc/pam.d/sudo-i $ cd $dir # <-- something that returns /etc/pam.d in this case
I'm asking this cause I recently became aware of the
$_ variable that has become useful. Was wondering if there's some other commandline fu that might come in handy.