Shell 如何在匹配模式后插入字符串
我有许多文件,其内容如下:Shell 如何在匹配模式后插入字符串,shell,Shell,我有许多文件,其内容如下: Class ABC { ... function getname(userid) { ... ... } function getprice(itemid,colorcode) { ... ... } } 我想向文件中添加测试点,以检查函数是否已被调用,因此,新文件应该如下所示,假设本例的文件名为/var/www/html/test.php: Class ABC { ... function
Class ABC
{
...
function getname(userid)
{
...
...
}
function getprice(itemid,colorcode)
{
...
...
}
}
我想向文件中添加测试点,以检查函数是否已被调用,因此,新文件应该如下所示,假设本例的文件名为/var/www/html/test.php:
Class ABC
{
...
function getname(userid)
{
echo /var/www/html/test.php getname(userid) is called
...
}
function getprice(itemid,colorcode)
{
echo /var/www/html/test.php getprice(itemid,colorcode) is called
...
}
}
字符串“echo{file name}{function name}被调用”将添加到文件中每个函数的开头
如何做到这一点?解决方案:
$ txr addecho.txr data
Class ABC
{
...
function getname(userid)
{
echo /var/www/html/test.php getname(userid) is called
...
...
}
function getprice(itemid,colorcode)
{
echo /var/www/html/test.php getprice(itemid,colorcode) is called
...
...
}
}
数据的内容与问题完全相同
@(repeat)
@ (cases)
function @name(@args)
{
@ (output)
function @name(@args)
{
echo /var/www/html/test.php @name(@args) is called
@ (end)
@ (or)
@line
@ (do (put-line line))
@ (end)
@(end)