Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- import
- context
- VirtualBox
- lsof
- 네트워크
- resource
- profile
- netsh
- ssh
- 단축키
- bash
- port
- Mac
- Windows 10
- find
- Eclipse
- Quartz
- grep
- JavaScript
- 줄바꿈 문자
- GIT
- xargs
- web.xml
- vscode
- Source
- Windows
- tomcat
- IntelliJ
- maVen
- plugin
Archives
- Today
- Total
develog
[bash] array 를 function parameter 로 전달 본문
- array 를 마지막 파라미터로 전달하고
- array 파라미터 위치만큼 shift 로 이동
- ($@) 로 받아서 루프 처리
test_pass_array.sh
function pass_array() {
param1=$1
param2=$2
shift
shift
list=($@)
echo param1 = $param1
echo param2 = $param2
for i in ${list[@]}
do
echo i = $i
done
}
array=(11 22 33 44 55)
pass_array 'aa' 'bb' ${array[@]}
test_pass_array.sh 실행
$ ./test_pass_array.sh
param1 = aa
param2 = bb
i = 11
i = 22
i = 33
i = 44
i = 55
Comments