linux bshell 学习

来源:互联网 发布:java加载不了 编辑:程序博客网 时间:2024/06/06 01:08

读取一个文件的第一行放到一个变量里面

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")