码迷,mamicode.com
首页 > 系统相关 > 详细

linux中if[[ $file == r* ]]的空格

时间:2017-05-20 17:14:48      阅读:283      评论:0      收藏:0      [点我收藏+]

标签:bsp   while   没有   pre   min   linux   file   结果   read   

ls $usridir/$line |  while read file
do
if [[ $file==access.log.*  ]]
then
echo $file "hahahah"
fi
done

[hadoop@mini2 study]$ ./t.sh
access.log.1 hahahah
test1.sh hahahah
t.sh hahahah

这个结果就不对,因为[[]]中的等号两端没有空格!,加上空格就对了

 

还有if后面必须有空格,then要和if在同一行then前面必须加上分号;

 

linux中if[[ $file == r* ]]的空格

标签:bsp   while   没有   pre   min   linux   file   结果   read   

原文地址:http://www.cnblogs.com/rocky-AGE-24/p/6882443.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!