读取一个文件的第一行放到一个变量里面
a=`sed -n 1p /root/a.txt`
查找一个字符串是否包含在一个变量里面
result=`echo $a | grep "hello"`
if [$result != ""]; then
echo "find the substr"
fi
或者
result=$(echo $a | grep "hello")
读取一个文件的第一行放到一个变量里面
a=`sed -n 1p /root/a.txt`
查找一个字符串是否包含在一个变量里面
result=`echo $a | grep "hello"`
if [$result != ""]; then
echo "find the substr"
fi
或者
result=$(echo $a | grep "hello")