Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/components/com_k2/models/item.php on line 763

怎么把命令输出结果赋值给变量(已解决)

我要把
awk '/eth0/{print $1 }' /proc/net/dev |sed 's/eth0://'
输出的结果赋值给变量 input

搞定了
input=$(awk '/eth0/{print $1 }' /proc/net/dev |sed 's/eth0://'
)

 

 

 

awk '/eth0/{print $1 }' /proc/net/dev |sed 's/eth0://'
不能用一个句子写出来?
awk -F "[: ]+" '/eth0/{print $3}' /proc/net/dev

 

 

http://cu.img168.net/static/image/common//icon_quote_e.gif); line-height: 1.6; zoom: 1; background-position: 100% 100%; background-repeat: no-repeat no-repeat;">假如一个命令ls有3个输出1,2,3;
我如何把1,2,3分别赋值给VAR1,VAR2,VAR3呢?
  1. #bash
  2. /home/lee#ls [0-9]
  3. 1  2  3
  4. /home/lee#while read file;do ((++n));eval var$n=$file;done< <(ls [0-9])
  5. /home/lee#echo $var1
  6. 1
  7. /home/lee#echo $var2
  8. 2
  9. /home/lee#echo $var3

 

 

 


Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169

Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478
back to top