In Bash, how can I obtain the directory path from the previous command's last argument
- by Beaming Mel-Bin
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?
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.