linux - shell脚本:ambiguous redirect
PHP中文网
PHP中文网 2017-04-17 13:24:35
0
1
1413
nlines=6
index=0
iplist=
while read line
do
    index=$[ ${index}+1 ]
    iplist[$index]="$line"
done < `sed -n "5,${nlines}p" "cloudfs_deploy.conf"`
echo ${iplist[@]}

运行这段脚本之后,总是在sed那行报ambiguous redirect错误
conf文件存在,有6行,我单独运行
nlines=6 ; sed -n "5,${nlines}p" "cloudfs_deploy.conf"
是没有错误的
求教这是什么原因?

PHP中文网
PHP中文网

认证0级讲师

모든 응답(1)
左手右手慢动作

因为第六行你使用了奇怪的语法。显然你想要的是:

bashnlines=6
index=0
iplist=
sed -n "5,${nlines}p" "cloudfs_deploy.conf" | while read line; do
    index=$[ ${index}+1 ]
    iplist[$index]="$line"
done
echo ${iplist[@]}
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!