Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • 162
    !:3 gets you the third one
    – Matt Dodge
    Commented Oct 10, 2016 at 22:08
  • 151
    !* gets you all of em
    – wonton
    Commented Jan 3, 2017 at 16:38
  • 111
    !! gets you the entire last command. Useful if you forgot to use sudo.
    – Un3qual
    Commented Jun 29, 2017 at 5:40
  • 67
    !:1-2 gets you all but the last of 3 arguments Commented Dec 13, 2017 at 18:57
  • 13
    Just a word of warning - if you use combined arguments like echo foo{,bar} baz, the command is recorded as printed and expands afterwards. With the above, using echo !:1 after resolves to echo foo{,bar} and then expands to echo foo foobar
    – Sean
    Commented Jul 12, 2018 at 14:14