bash流程操作语法
2008-03-26 15:46
337 查看
1: if 条件语句
(1) if condition;
then command;
fi
(2) if condiont;
then command
else
command
fi
(3) if condition;then
command
elif condition;then
command;
else
comand;
fi
(4)
case express in case1)
command_list;;
case2)
command_list;;
esac
例:
case $space in
[1-6]*)
message = ""
;;
[7-8]*)
message=""
99)
message=""
;;
*)
message=""
esac
2 for语句
(1)for name in [in word]; do list;done
for filename in `ls`;
do
cat $filename
done
(2)for((expr1;expr2;expr3)); do list;done
for(i=0;i<10;i++);
do
echo $i
done
其它
$# 参数的总数, $? 返回给父进程的退出状态码
条件判断:
[-d 文件] 文件存在且是一个目录
[-e 文件] 文件存在
[-f 文件] 文件存在且为普通文件
[-h 文件] 符号链接文件 [L file]
[-p file] 管道
[-s file] 比零字节大的文件
[-r file] 存在且是可读
[-w file] 存在且可写
[-x file] 可执行
[-S file) socket file
[-z string] string长度为零
[-n string] string长度非零
[file1 nt file2] file1比file2新,或者file1 存在而file2不存在
[file1 ot file2] file1比file2旧,或者file1不存在面file2存在
(1) if condition;
then command;
fi
(2) if condiont;
then command
else
command
fi
(3) if condition;then
command
elif condition;then
command;
else
comand;
fi
(4)
case express in case1)
command_list;;
case2)
command_list;;
esac
例:
case $space in
[1-6]*)
message = ""
;;
[7-8]*)
message=""
99)
message=""
;;
*)
message=""
esac
2 for语句
(1)for name in [in word]; do list;done
for filename in `ls`;
do
cat $filename
done
(2)for((expr1;expr2;expr3)); do list;done
for(i=0;i<10;i++);
do
echo $i
done
其它
$# 参数的总数, $? 返回给父进程的退出状态码
条件判断:
[-d 文件] 文件存在且是一个目录
[-e 文件] 文件存在
[-f 文件] 文件存在且为普通文件
[-h 文件] 符号链接文件 [L file]
[-p file] 管道
[-s file] 比零字节大的文件
[-r file] 存在且是可读
[-w file] 存在且可写
[-x file] 可执行
[-S file) socket file
[-z string] string长度为零
[-n string] string长度非零
[file1 nt file2] file1比file2新,或者file1 存在而file2不存在
[file1 ot file2] file1比file2旧,或者file1不存在面file2存在
相关文章推荐
- java语法基础-程序流程控制-选择结构-switch语句
- 视频通过的流程API调用操作控制
- Git客户端安装图文详解如何安装配置GitHub操作流程攻略
- 测试基础 testlink操作流程及Mantis整合
- mysql之数据库操作基本语法
- Activiti工作流框架学习(二)——使用Activiti提供的API完成流程操作
- (转)私募基金机构设立、牌照申请、后续运营的最新政策规定和操作流程
- PayPal提现操作流程
- Linux第一课 命令行BASH的基本操作
- SAP SD模块操作流程
- Git客户端图文详解如何安装配置GitHub操作流程攻略
- git多人操作流程
- Linux 入门记录:一、命令行 Bash 的基本操作
- Kotlin 语法上的一些亮眼操作
- [java语法]基本语法(3) 程序控制流程
- SEO的操作流程梗概
- 配置NDK Cygwin .bash_profile:行47: 语法错误: 未预期的文件结尾 syntax error: unexpected end of file 解决
- mysql基于备份进行drop操作恢复的全部测试流程。
- C#操作xml之xpath语法