-z
으로 문자열이 비어 있는지 테스트하고 문자열이 비어 있지 않은지 여부를 -n
으로 테스트 할 수 있다는 것을 알고 있습니다. 그래서 우분투 10.10에서 스크립트 작성 : 놀랍게도bash 빈 문자열 비교 문제
#!/bin/bash
A=
test -z $A && echo "A is empty"
test -n $A && echo "A is non empty"
test $A && echo "A is non empty"
str=""
test -z $str && echo "str is empty"
test -n $str && echo "str is non empty"
test $str && echo "str is non empty"
을, 그것은 출력 :
A is empty
A is non empty
str is empty
str is non empty
나는 것은 그것은 어떤 리눅스 전문가가 이유를 설명 할 수
A is empty
str is empty
을해야 하는가?
감사합니다.