Another ! shortcut is !$. This will give you the end of the previous command. So if my previous command was:
grep fred /etc/passwd
doing !$ would give me /etc/passwd. This can be handy. Say for example the user fred exists on the system, and grep returns his record from /etc/passwd. If there is something I see in one of the fields that I wish to change, all I need to do (provided that grep was the last command I did) is:
vi !$
This will expand to
vi /etc/passwd
If you are not sure how !$ will expand for you (ie., you cannot remember for certain what your last command was exactly), you can use the :p option:
vi !$:p
No comments:
Post a Comment