매우 비효율적 인이 스크립트를 사용하십시오. 쉘 스크립팅을 처음 사용합니다. matchFS() 함수의 if 절 근처에서 오류가 발생했습니다. 아래에 오류를 게시했습니다. 누구든지 나에게 약간의 지침을 제공 할 수 있습니까?bash에서 조건부 연산자 예상 오류가 발생했습니다
#!/bin/bash
function matchFS() {
usage=$(df -h | tail -n +2 | awk '{print $5}' | sed 's/%//g')
usagearr=($usage)
for i in "${usagearr[@]}"
do
if [[ $1 eq "${usagearr[$i]}" ]]; then
# print matching row from df -h
fi
done
}
usage=$(df -h | tail -n +2 | awk '{print $5}' | sed 's/%//g')
usagearr=($usage)
len=${#usagearr[@]}
for ((i=0; i<$len; i++)) # we have to use (()) here to represent the c style for loop
do
if [ "${usagearr[$i]}" -gt "10" ]; then
matchFS ${usagearr[$i]}
fi
done
오류 : 라인 13 : 조건 이항 연산자가 라인 (13) 예상 : [[$ 1 당량은 "] 49] 경우 eq' line 13:
근처에 구문 오류, 당신은 help test
보면 다음 '
가 http://www.shellcheck.net/ – Cyrus