shell命令学习(一)
来源:互联网 发布:h5源码比较好的网站 编辑:程序博客网 时间:2024/05/16 17:38
shell命令学习之for
for 变量 in 值
do
声明
done
例子:for a in a b x
do
echo $a
done
输出:
a
b
x
while do 命令学习
#!/bin/sh
echo "请输入密码"
read trythis
while [ "$trythis" != "s" ]; do
echo "sorry you type word is increcct"
read trythis
done
exit 0
#!/bin/sh
echo "case测试"
read day
case "$day" in
yes|y|YES) echo "right";;
N*|n*) echo "wrong";;
esac
exit 0
&& 以及||学习
touch file_one
touch file_two
if [ -f file_one ] && echo "hello" && [ -f file_two ] && echo " there"
then
echo "in if"
else
echo "in else"
fi
exit 0
-------------------------------------------------
执行./bin.sh param
param参数需要 $1 $2来接受参数
-----函数学习
#!/bin/sh
foo(){
echo "请输入你的名字"
while true
do
echo -n "输入yes 或者 no"
read x
case "$x" in
y | yes ) return 0;;
n | no ) return 1;;
*) echo "输入错误";;
esac
done
}
echo "start exe script"
if foo "$1"
then
read name
echo "你好,$1,很好的名字"
else
echo "无所谓"
fi
exit 0
- shell命令学习(一)
- Shell命令学习(一)
- shell学习之sort命令(一)
- Shell脚本学习(一)Shell命令基础
- Linux Shell 命令学习一
- shell学习--一天一命令--set
- shell学习(一)
- shell学习(一)
- shell学习(一)
- adb shell 命令(一)
- 常用shell命令(一)
- shell相关命令(一)
- Shell命令学习(二)
- Shell命令学习(三)
- Shell命令学习(四)
- shell学习笔记(一)
- Shell学习笔记(一)
- shell 学习笔记(一)
- Hibernate 一对一外键单向关联
- Android框架UniversalImageLoader
- 用JavaFX构建部署Android应用
- LeetCode: Edit Distance
- 独木舟上的旅行
- shell命令学习(一)
- Codeforces 485 A. Factory 暴力
- iOS图形编程基础知识总结
- xcode6模拟器运行程序后不显示键盘
- STM32启动文件选择说明
- selenium python选中列表中的某一项
- 图像文字识别软件好用吗
- iOS里的MVC(转载)
- PHP上传文件注意事项