0

How can I get second argument from the end of arguments line in bash?

1

2 Answers 2

4

To print the second last argument use:

echo "${@:(-2):1}"
1

one way in Bash

set -- ${@:(-2)}
echo $1

or simply

echo ${@:(-2):1}
1
  • @Dennis, thks for the comment
    – kurumi
    Commented Feb 28, 2011 at 15:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.