我知道如何将 BASH 变量设置为等于命令的输出,但它在“top”命令对我来说不起作用,请参见下文
cat aTOPFWK.sh
OUTPUT = $(top -b -n 1 | egrep 'fwk3' | awk '{print $9}')
echo "${OUTPUT}"
./aTOPFWK.sh: line 3: OUTPUT: command not found
答案1
去掉“=”周围的空格:
OUTPUT=$(top -b -n 1 | egrep 'fwk3' | awk '{print $9}')
echo "${OUTPUT}"