shell if [] 条件 and read
来源:互联网 发布:同信证券交易软件 编辑:程序博客网 时间:2024/04/26 12:34
Recent week I deal with the shell script met many problem.
firstly ksh has some grammar different with bash,so you much well know what sh type you deal with.
about ksh if condition should take care of
if [[ $line == $xslSignBegin ]]; then
echo "$line"
fi
1. there is space between if and "[[" , operators and "==" , "[[ "and operators,"]] "and operator ,";" and then
(so many spaces)
2.use "=" if you don't have space in operator . and bash use = not ==
the following three days I done a shell
if you met a problem between like test:unknown operator try ' '
#!bin/ksh
mozillaDir=/usr/share/mime/packages
fileName=freedesktop.org.xml
fileNameBack=freedesktop.org.xmlback
if [ ! -f $mozillaDir/$fileNameBack ]; then
if [ 'id 2> /dev/null | cut -d"=" -f2 2> /dev/null | cut -d"(" -f1 2> /dev/null' ]; then
cp $mozillaDir/$fileName $mozillaDir/$fileNameBack
xslSignBegin="<mime-type type=/"text/x-xslt/">"
commentBegin="<!--"
commentEnd="-->"
xslSignEnd="</mime-type>"
isEdit=false
addComment=false
while read line
do
if [[ $line == $xslSignBegin ]]; then
isEdit=true
addComment=true
line=$commentBegin$line
elif [[ $addComment = true && $line == $xslSignEnd ]]; then
line=$line$commentEnd
addComment=false
fi
echo "$line" >> $mozillaDir/temp
done < $mozillaDir/$fileName
if [[ $isEdit = true ]]; then
mv $mozillaDir/$fileName $mozillaDir/$fileName"update"
mv $mozillaDir/temp $mozillaDir/$fileName
rm $mozillaDir/temp
isEdit=false
echo "exectue command update"
update-mime-database /usr/share/mime
fi
else
echo "You should switch root user to config Mozilla environment to support text//xsl MIME type or change firefox browser in order to run successfully!"
fi
fi
- shell if [] 条件 and read
- shell if 条件
- [shell] if判断条件
- SHELL----IF条件判断
- Shell IF条件判断
- shell--if条件判断
- shell----- 条件选择 if && case
- shell if 条件语句解析
- Linux shell if条件判断
- shell----if条件判断参数
- shell中条件判断if
- shell中if多重条件
- Linux Shell if条件判断
- shell脚本----if判断条件
- shell中IF条件判断
- shell IF条件判断,判断条件
- shell条件嵌套(if条件语句)
- shell条件嵌套(if条件语句)
- Html中Document和Event里各种坐标的定义
- xcopy参数(转)
- 高雅的活着……
- 强大的前端绘制图表(jQuery)插件
- 聚集索引与非聚集索引(转载)
- shell if [] 条件 and read
- 两个select之间option的互相添加操作(jquery实现)
- 范式 1NF 2NF 3NF
- 感冒
- Alter修改表结构对数据存储的影响(一)
- SEO网站优化在企业中应该处于什么位置?
- 用想要的域名运行你的本地Web应用
- 编程思想+++++精华
- Google Wave,新Web时代的沟通平台(多图,视频)ZZ