怎么把命令输出结果赋值给变量(已解决)
- font size decrease font size increase font size
- Print Email
我要把
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呢?
( ! ) 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 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0009 | 412424 | {main}( ) | .../index.php:0 |
2 | 0.1076 | 4262856 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.1076 | 4262856 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.3732 | 11453840 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.3743 | 11478536 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.3754 | 11533864 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.3758 | 11561264 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.3874 | 11960896 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.3875 | 11960896 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.4022 | 12611600 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.4022 | 12611600 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.4085 | 12982640 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.4111 | 13003008 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.5206 | 15844664 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.5206 | 15844664 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.5244 | 16017600 | include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ) | .../HtmlView.php:701 |
- Published in CentOS 6
- Read 2937 times
( ! ) 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 | ||||
---|---|---|---|---|
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0009 | 412424 | {main}( ) | .../index.php:0 |
2 | 0.1076 | 4262856 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.1076 | 4262856 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.3732 | 11453840 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.3743 | 11478536 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.3754 | 11533864 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.3758 | 11561264 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.3874 | 11960896 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.3875 | 11960896 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.4022 | 12611600 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.4022 | 12611600 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.4085 | 12982640 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.4111 | 13003008 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.5206 | 15844664 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.5206 | 15844664 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.5244 | 16017600 | include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ) | .../HtmlView.php:701 |