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.

4
  • 11
    Best answer, since it also includes the next to last arg. Thanks!
    – e40
    Commented Jul 7, 2013 at 0:54
  • 2
    Steven, I don't know what you did to land in the Penalty Box, but I am loving your work on here. Commented Sep 22, 2017 at 15:09
  • 4
    yes. simply the best. all but command and last argument ${@: 1:$#-1}
    – Dyno Fu
    Commented Jan 9, 2019 at 7:52
  • 1
    @DynoFu thank you for that, you answered my next question. So a shift might look like: echo ${@: -1} ${@: 1:$#-1}, where last becomes first and the rest slide down
    – Mike
    Commented Apr 18, 2019 at 19:46