내용

  • $@은 환경변수 $FS 설정된 구분자를 통해 위치 매개변수를 분리하여 보관합니다.
  • $*은 모든 위치매개변수를 하나의 스트링으로 보관합니다.
#!/bin/sh
 
# $@를 for 구문을 통해 출력
 
echo "exam: \$@=$@"
 
for pos_param in "$@"
do 
	echo $pos_param
done
 
# $*를 for 구문을 통해 출력
 
echo "exam: \$*=$*"
 
for pos_param in "$*"
do 
	echo $pos_param
done

실행결과

# bash test.sh first second third 
exam: $@=first second third
first
second
third
exam: $*=first second third
first second third

연관 페이지

참고 문헌 / 사이트