#!/bin/bash
#從環境變量中過濾出包含"USER"字符的行,結果為USER=root; 然后使用字符串截取命令cut,按 分隔符為"=",取第二列數據 的參數取出root值
test=$(env | grep "USER" | cut -d "=" -f 2)
# "=="是字符串判斷是否相等命令 ps:[]里的數據,兩邊需要加空格,否則會報命令錯誤
if [ "$test" == "root" ]
then
echo "this is my first shell code,go next"
fi