Example: I type
man ls, than I want to get
!! I can get
man ls but how do I get
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You can select particular word from last typed command with
!!: and a word designator. As a word designator you need
0. You may find
$ useful too. From
0 (zero) The zeroth word. For the shell, this is the command word.
^ The first argument. That is, word 1.
$ The last argument.
So in your case try:
In interactive mode, the easiest way to do this is just a keystroke combination alt+0 and alt+.. The shortcut alt+. means "recall n-th word from the previous line" (by default the last one) and alt+0 gives it an argument 0.
This should work for interactive bash on most systems (more generally, all shells that use
readline as its input library).