I've alway been quite fond of
bash history expansion and in particular
!!
(previous command) and
!$
(last argument of previous command) but today I discovered a new trick, the
:h
modifier. This takes a word and removes file file name, here I am using it in action.
buckett@oucs-matthewb:~ $ sudo vi /opt/tivoli/tsm/client/ba/bin/incl.excl.SAVE
buckett@oucs-matthewb:~ $ cd !$:h
cd /opt/tivoli/tsm/client/ba/bin
buckett@oucs-matthewb:/opt/tivoli/tsm/client/ba/bin $ mv incl.excl.SAVE incl.excl
mv: cannot move `incl.excl.SAVE' to `incl.excl': Permission denied
buckett@oucs-matthewb:/opt/tivoli/tsm/client/ba/bin $ sudo !!
sudo mv incl.excl.SAVE incl.excl
Now I just have to remember it for more than a few days for it to seep into my normal usage of the shell.
No comments:
Post a Comment