I am starting to learn some Regex, therefore I use this command repeatedly:
grep pattern /usr/share/dict/american-english
Only the part with pattern changes, so I have to write the long expression "/usr/share/dict/american-english" again and again.
Someone made the remark that it is possible to expand an argument of a command from the command history by typing cryptic character combinations instead of the full expression.
Could you tell me those cryptic character combinations ?
Best Answer
You can use
<M-.>
(or<Esc>.
if your Meta key is being used for something else), that is, Meta-dot (or <esc> dot), where Meta is usually the Alt key, to recall the last argument of the previous command. So, first you would typeAnd then if you wanted to grep for something else, you would type
After typing a space and then Esc. (that is, first pressing the escape key, and then the period key):
You can also use either of the following:
Where
!:2
and!$
mean "second argument" and "last argument" respectively.