- 论坛徽章:
- 0
|
回复 2# klainogn
#!/bin/bash
#program:
#history
#2019/3/5
function check_nonde_p_state
{
while test $# -gt 0
do
if [ "$1" == "Normal" ];then
shift
nonde_p_state=normal
else
nonde_p_state=abnormal
break
fi
done
}
#计算需要获取的起始行号
first_row_num=$((`cat 123.log | grep -n "Coordinator State" | cut -d: -f1` + 4))
#设置需要获取的行数
row_num=4
#获取数据
get_node_p_state=`sed -n "$first_row_num,\$p" 123.log | awk '{print $6}'`
#echo $get_node_p_state
check_nonde_p_state $get_node_p_state
#输出Coordinator 状态
echo $nonde_p_state
我现在的代码是这样的,但是有报错:
[root@test01 opt]# sh node_stat.sh
sed: -e expression #1, char 3: unexpected `,' [root@test01 opt]# sh -x node_stat.sh
++ cut -d: -f1
++ grep -n 'Coordinator State'
++ cat 123.log
+ first_row_num=18
+ row_num=4
++ awk '{print $6}'
++ sed -n 18, 123.log
sed: -e expression #1, char 3: unexpected `,'
+ get_node_p_state=
+ check_nonde_p_state
+ test 0 -gt 0
+ echo
|
|