shell 学习
2024-08-27 19:56:15
将maven 项目里面的jar 包导出目录: 在项目里面执行:
mvn dependency:copy-dependencies -DoutputDirectory=lib
shell 参数之间必有空格分开,变量申明不能有空格
while [ "$i" != "100" ]
i=$(($i+1))
#!/bin/sh
case $1 in
"one")
echo "Your choice is ONE"
;;
"two")
echo "Your choice is TWO"
;;
esac
#!/bin/sh
read -p "Please input (Y/N): " yn
[ "$yn" == "Y" -o "$yn" == "y" ] && echo "OK, continue" && exit 0
[ "$yn" == "N" -o "$yn" == "n" ] && echo "Oh, interrupt!" && exit 0
echo "I don't know what your choice is" && exit 0
#!/bin/sh
while [ "$yn" != "yes" -a "$yn" != "YES" ]
do
read -p "please in put you process" yn
done
echo "you answer is r"
until [ "$yn" == "yes" -o "$yn" == "YES" ]
do
read -p "Please input yes/YES to stop this program: " yn
done
echo "OK! you input the correct answer." until [ "$yn" == "yes" -o "$yn" == "YES" ] 参数之间有空格不然会报 [: too many arguments错误
#!/bin/sh
i=0
s=0
while [ "$i" != "100" ]
do
i=$(($i+1))
s=$(($s+$i))
done
echo "the end of total is : $s"
输出是:5050
for animal in dog cat elephant
do
echo "there are ${animal}"
done
输出结果:
there are dog
there are cat
there are elephant
查看当前有哪些用户:
#!/bin/bash
users=$(cut -d ':' -f1 /etc/passwd)
for username in $users
do
id $username
finger $username
done
检查服务器是否通
#!/bin/sh
network="192.168.1" # 先定义一个网域的前面部分!
for sitenu in $(seq 1 100) # seq 为 sequence(连续) 的缩写之意
do
# 底下的程序在取得 ping 的回传值是正确的还是失败的!
ping -c 1 -w 1 ${network}.${sitenu} &> /dev/null && result=0 || result=1
# 开始显示结果是正确的启动 (UP) 还是错误的没有连通 (DOWN)
if [ "$result" == 0 ]; then
echo "Server ${network}.${sitenu} is UP."
else
echo "Server ${network}.${sitenu} is DOWN."
fi
done
最新文章
- Shell脚本_位置参数和预定义参数
- RabbitMQ学习笔记3-使用topic交换器
- Vi/Vim查找替换使用方法
- php中一个";异类";语法: $a &;&; $b = $c;
- Stream语法详解
- ASP.NET之HttpModule拦截404异常
- 【重大bug】viewpager使用的时候加载数据应该在setOnPageChangeListener里加载
- tomcat内存溢出之PermGen space
- SWING中文件的上传
- zookeeper 启动 zookeeper_server.pid: Permission denied
- Day5--Python--字典
- vue v-time指令封装(接口返回时间戳 在到日期转换)
- Scrum Meeting博客汇总
- 虚拟 DOM
- The hyperlink for cell A2 references relation rId1, but that didn't exist!
- hdu 4864 任务分配贪心
- AssetBundleMaster
- android动手写控件系列——老猪叫你写相机
- MS Chart Control 學習手記(二) - 圓餅圖
- 鼠标经过的图片高亮显示,其余变暗效果[xyytit]
热门文章
- 使用 Camtasia Recorder显示 “ camtasia an error occurred in the recorder: video codec open failed ”
- DWZ在APS.NET WebForm中的使用(一)
- OC学习中遇到的问题总结
- SQL子句执行顺序和Join的一点总结
- HDU 1057 - A New Growth Industry
- [?]Unity快捷键
- 在Yii框架中使用PHPExcel
- rotate.js实现图片旋转 (chrome,IE,firefox都可以实现)
- 纯css改变下拉列表select框的默认样式
- js Array 学习