此命令从日志中获取所有用户。效果很好
grep $srcIP $cFilename | grep "Username: " | awk -F"Username: " '{print $2}'| awk -F"," '{print $1}' | sort -u
所以它会显示
user1 user2 user3 user4 etc...
我将它分配给一个变量,到目前为止一切顺利
getUser=$(grep $srcIP $cFilename | grep "Username: " | awk -F"Username: " '{print $2}'| awk -F"," '{print $1}' | sort -u)
如果我想显示第二个用户
echo $getUser | awk '{print $2}'
它将显示
user2
但是如果我将该命令分配给一个变量
tmp=$($getUser | awk '{print $2}')
现在,我收到一条错误消息
user2: command not found
谁知道如何将此命令语句分配给变量?
$getUser | awk '{print $2}'