티스토리 뷰

공부

[shell] ${@:$n:1}

승가비 2024. 1. 29. 00:43
728x90
#!/bin/bash
n=2
echo ${@:$n:1}

https://stackoverflow.com/questions/10749976/bash-scripting-n-th-parameter-of-when-the-index-is-a-variable

 

BASH scripting: n-th parameter of $@ when the index is a variable?

I want to retrieve the n-th parameter of $@ (the list of command line parameters passed to the script), where n is stored in a variable. I tried ${$n}. For example, I want to get the 2nd command ...

stackoverflow.com

 

728x90
댓글