strange behavior when using linux shell
2015-12-02 16:20
666 查看
cat testfile aa bb cc
#!/bin/sh ruleID=100 cat testfile | while read line do case $line in aa) echo "@@@aa@@@ruleID = $ruleID" ruleID=10 echo "@@@aa@@@ruleID = $ruleID" ;; bb) ruleID=20 echo "@@@bb@@@ruleID = $ruleID" test $ruleID ;; esac echo "@@@out of case@@@ruleID = $ruleID" done echo "@@@out of do while@@@ruleID = $ruleID"
sh aa.sh @@@out of case@@@ruleID = 100 //the ruleID's value get out of do while loop @@@aa@@@ruleID = 100 @@@aa@@@ruleID = 10 @@@out of case@@@ruleID = 10 @@@bb@@@ruleID = 20 @@@out of case@@@ruleID = 20 @@@out of case@@@ruleID = 20 @@@out of do while@@@ruleID = 100 //the ruleID's value come back!!
why this kind of situation happen??
相关文章推荐
- shell脚本调试报错:"syntax error: unexpected end of file"
- 转CentOS — MySQL备份 Shell 脚本
- adb shell su 后不能写命令
- HBase的Shell操作
- XenDesktop 7.6 powershell commands cheat sheet
- Linux shell 的字符串截取
- bash 基本功能
- awk中使用shell的环境变量
- shell 基本学习
- SHELL脚本的一些特殊用法
- Linux Shell下的后台运行及其前台的转换
- 一些值得收藏的PowerShell工具
- shell 将当前目录下所有文件的文件名逆序
- SimpleGraphX PageRank shell
- shell脚本调试之工具——bashdb
- xshell使用rz,sz指令实现文件的上传,下载功能
- shell 学习记录
- shell脚本学习(二)
- spark-shell on yarn 出错解决【启动命令bin/spark-shell --master yarn-client出现错误,类ExecutorLauncher 找不到】
- 企业shell编程基础问题解决实践-是骡子是马溜溜!