shell基础
来源:互联网 发布:三维人像综合数据门 编辑:程序博客网 时间:2024/05/18 01:30
1 shell的集合
declare -A ihmap=()
FILE_ALL=/opt/config/iphost
for d in `cat $FILE_ALL`;do eval $(echo $d|awk -F',' '{printf("a=%s b=%s",$2,$1)}');ihmap[$a]=$b;done
countha=0
IFS=';'
for hips in ${hadoopIp[@]}; do
let countha+=1
IFS=','
for hip in ${hips[@]};do
if [ $countha == 1 ];then
echo ${ihmap[$hip]},$hip,root,root,NN>>/opt/config/iphostuserpwdtype
elif [ $countha == 2 ];then
echo ${ihmap[$hip]},$hip,root,root,DN>>/opt/config/iphostuserpwdtype
fi
done
done
2 文件的锁定及进程的存在判断
脚本1 start.sh:
flock -xn /var/run/aa.lock -c 'sh /opt/scripts/start_all.sh $1'
脚本2 start_all.sh:
真正执行任务的脚本,略
进程判断
可尝试:
infos=$(ps -ef|grep '' |grep -v grep);
3 shell 只处理文件倒数第二行
# cat tt
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
# sed '$!N;$s/,//' tt
1,
2,
3,
4,
5,
6,
7,
8,
9
10,
只处理倒数第三行:
sed -n ':a;${s/;/,/;p;q};N;4,${P;D};ba' tt
sed博大精深,慢慢积累咯~
- Shell基础
- Shell 基础
- Shell 基础
- shell基础
- shell 基础
- shell基础
- shell基础
- Shell基础
- shell基础
- shell基础
- shell基础
- Shell基础:
- shell基础
- shell 基础
- shell基础
- shell基础
- shell基础
- shell基础
- mogod启动时出现故障
- Fastdfs+nginx
- 使用otter实现MySQL跨机房双向同步 工作流程 环境 目标 名词解释 安装 配置 配置mysql 导入 manager 系统表 导入 node 同步算法依赖的系统表 管理配置 添加zookee
- matplotlib-2.1.0-none-cp35m-win_amd64.whl is not a supported wheel on this platform
- mysql基础
- shell基础
- 生成Token的工具类TokenProccessor
- openstack 对接 NFS 存储
- linux命令之创建符号连接-ln
- Day1
- C语言的变量-1
- javascript循环不能正确输出i值的问题。
- 【云星数据---Apache Flink实战系列(精品版)】:Apache Flink批处理API详解与编程实战024--DateSet实用API详解024
- Mac电脑安装及终端命令使用mysql