awk中使用shell的环境变量
- font size decrease font size increase font size
- Print Email
awk中使用shell的环境变量
一:"'$var'"
这种写法大家无需改变用'括起awk程序的习惯,是老外常用的写法.如:
var="test"
awk 'BEGIN{print "'$var'"}'
这种写法其实际是双括号变为单括号的常量,传递给了awk.
如果var中含空格,为了shell不把空格作为分格符,便应该如下使用:
var="this is a test"
awk 'BEGIN{print "'"$var"'"}'
二:'"$var"'
这种写法与上一种类似.如果变量含空格,则变为'""$var""'较为可靠.
三.把括起awk程序的''变为"",使用"$var"
如:
$var="this is a test"
awk 'BEGIN{print "$var"}"
这是因为在""里$是特殊字符,而在''里$是普通字符.
四:export 变量,使用ENVIRON["var"]形式,
如:
$var="this is a test";export $var
awk 'BEGIN{print ENVIRON["var"]}'
五:当然也可以使用-v选项
如:
$var="this is a test"
awk -vnvar="$var" '{print nvar}'
这样便把系统变量定义成了awk变量.
( ! ) 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.0010 | 403560 | {main}( ) | .../index.php:0 |
2 | 0.1522 | 1321344 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.1522 | 1321344 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.5065 | 2979736 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.5073 | 3004320 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.5094 | 3059648 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.5098 | 3076704 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.5210 | 3220792 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.5210 | 3220792 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.5436 | 3489872 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.5436 | 3489872 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.5475 | 3508392 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.5513 | 3528808 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.6222 | 4093584 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.6222 | 4093584 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.6252 | 4267984 | 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 2532 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.0010 | 403560 | {main}( ) | .../index.php:0 |
2 | 0.1522 | 1321344 | Joomla\CMS\Application\SiteApplication->execute( ) | .../index.php:49 |
3 | 0.1522 | 1321344 | Joomla\CMS\Application\SiteApplication->doExecute( ) | .../CMSApplication.php:196 |
4 | 0.5065 | 2979736 | Joomla\CMS\Application\SiteApplication->dispatch( ) | .../SiteApplication.php:233 |
5 | 0.5073 | 3004320 | Joomla\CMS\Component\ComponentHelper::renderComponent( ) | .../SiteApplication.php:194 |
6 | 0.5094 | 3059648 | Joomla\CMS\Component\ComponentHelper::executeComponent( ) | .../ComponentHelper.php:377 |
7 | 0.5098 | 3076704 | require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ) | .../ComponentHelper.php:402 |
8 | 0.5210 | 3220792 | K2ControllerItem->execute( ) | .../k2.php:64 |
9 | 0.5210 | 3220792 | K2ControllerItem->display( ) | .../BaseController.php:710 |
10 | 0.5436 | 3489872 | K2ControllerItem->display( ) | .../item.php:78 |
11 | 0.5436 | 3489872 | K2ControllerItem->display( ) | .../controller.php:19 |
12 | 0.5475 | 3508392 | Joomla\CMS\Cache\Controller\ViewController->get( ) | .../BaseController.php:663 |
13 | 0.5513 | 3528808 | K2ViewItem->display( ) | .../ViewController.php:102 |
14 | 0.6222 | 4093584 | K2ViewItem->display( ) | .../view.html.php:742 |
15 | 0.6222 | 4093584 | K2ViewItem->loadTemplate( ) | .../HtmlView.php:230 |
16 | 0.6252 | 4267984 | include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ) | .../HtmlView.php:701 |