본문으로 건너뛰기
0%
1분 미만 (68 단어) ko

Bash list?

Categories TechSavvy Bash
Tags #TechSavvy #ProgrammingLanguage #Bash

array(list)

Bash 에서는 괄호로 Array를 표현가능하다 그 안에서 구분자는 아무래도 띄어쓰기(space bar) 이다

$ cat array_ex.sh
#!/bin/bash
lists=("a" b "c")
echo ${lists[1]}
echo ${lists[0]}
echo ${lists[3]}
echo ${lists[2]}
$ sh array_ex.sh
b
a

c

아래 예제와 같이 Slicing도 지원된다.

lists=("V0.1.0" "V1.0.0")
echo "[1] : "${lists[1]}
echo "[0] : "${lists[0]}
echo "[3] : "${lists[3]}
echo "[-1] : "${lists[-1]}

selected=${lists[-1]}
echo "selected : "$selected

Appendix. References

Share this article

Found this helpful? Share it with your network

Join the Discussion

Share your thoughts and connect with other readers

댓글

GitHub 계정으로 로그인하여 댓글을 남겨보세요. 건설적인 의견과 질문을 환영합니다!

댓글을 불러오는 중...