标签:lang from note support 查看 学习 style ica 存在
我会定期的把看到的一些好的shell和py脚本搜集在这里,供参考学习:
shell资源:
https://github.com/lannyMa/ops_doc/tree/master/LazyManage
yum install man-pages-zh-CN -y
echo 'LANG="zh_CN.UTF-8"' >> ~/.bashrc
echo 'LANGUAGE="zh_CN:zh"' >> ~/.bashrc
source ~/.bashrc
shell自动补全
yum install bash-com*
查看shell选项
man sh
set -ue 遇到错误退出
-x debug模式
{2..10}
seq 10
for ((i=0,i<10;i++));do done
for i in `ls /`;do
echo ${i}_$(date +%F)
done
man sh
-z 如果变量值长度为0,则为真
-d
-f
-w 可写
-x 可执行 --启动脚本是否可执行
-e 是否存在.--配置文件是否存在
$[$a+$b]
#!/usr/bin/env bash
#/sys/class/net/eth0/statistics/rx_packets: 收到的数据包数据
#/sys/class/net/eth0/statistics/tx_packets: 传输的数据包数量
#/sys/class/net/eth0/statistics/rx_bytes: 接收的字节数
#/sys/class/net/eth0/statistics/tx_bytes: 传输的字节数
#/sys/class/net/eth0/statistics/rx_dropped: 当收到包数据包下降的数据量
#/sys/class/net/eth0/statistics/tx_dropped: 传输包数据包下降的数据量
function get_pkgs(){
rx_packets=$(cat /sys/class/net/eth0/statistics/rx_packets)
tx_packets=$(cat /sys/class/net/eth0/statistics/tx_packets)
rx_bytes=$(cat /sys/class/net/eth0/statistics/rx_bytes)
tx_bytes=$(cat /sys/class/net/eth0/statistics/tx_bytes)
rx_kb=$[$rx_bytes/1024/1024]
tx_kb=$[$tx_bytes/1024/1024]
}
function print(){
get_pkgs
echo -n "数据包/收: ";
echo -n "数据包/发: ";
echo -n "数据包/发-字节: "${rx_kb} Mb;
echo -n "数据包/收-字节: "${tx_kb} Mb;
sleep 1
}
while :;do
print
echo
sleep 1
done
function help(){
echo "usage: xxx
this is a test
"
}
# 参数总数
#if [ $# -eq 0 ];then
# help
#elif [ $1 == "22" ];then
# echo "22 happy"
#else
# echo "default..."
#fi
# 参数是否存在
if [ ! -z "$1" ];then
echo $1
else
echo "very sad"
fi
参考: https://github.com/jenkinsci/docker/blob/master/plugins.sh
set -e
echo "WARN: plugins.sh is deprecated, please switch to install-plugins.sh"
if [ -z "$1" ]
then
echo "
USAGE:
Parse a support-core plugin -style txt file as specification for jenkins plugins to be installed
in the reference directory, so user can define a derived Docker image with just :
FROM jenkins
COPY plugins.txt /plugins.txt
RUN /usr/local/bin/plugins.sh /plugins.txt
Note: Plugins already installed are skipped
"
exit 1
else
JENKINS_INPUT_JOB_LIST=$1
if [ ! -f "$JENKINS_INPUT_JOB_LIST" ]
then
echo "ERROR File not found: $JENKINS_INPUT_JOB_LIST"
exit 1
fi
fi
标签:lang from note support 查看 学习 style ica 存在
原文地址:http://www.cnblogs.com/iiiiher/p/8016181.html