Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix 如何在调用sql文件的scipt日志中包含新行,而该sql文件会给出很多错误_Unix - Fatal编程技术网

Unix 如何在调用sql文件的scipt日志中包含新行,而该sql文件会给出很多错误

Unix 如何在调用sql文件的scipt日志中包含新行,而该sql文件会给出很多错误,unix,Unix,我编写了一个shell脚本,它调用另一个sql文件,在oracle中禁用触发器。 但这个sql文件生成了很多oracle错误,在脚本的日志文件中,我得到了如下响应 ORA-21021——oracle错误ORA-20111——oracle错误 我想添加一个新行,获取oracle错误,例如 ORA-21021 --** oracle errors** ORA-20111 --** oracle errors** 如何做到这一点 sql文件代码: alter trigger trigger_name

我编写了一个shell脚本,它调用另一个sql文件,在oracle中禁用触发器。 但这个sql文件生成了很多oracle错误,在脚本的日志文件中,我得到了如下响应
ORA-21021——oracle错误ORA-20111——oracle错误
我想添加一个新行,获取oracle错误,例如

ORA-21021 --** oracle errors**
ORA-20111 --** oracle errors**
如何做到这一点

sql文件代码:

alter trigger trigger_name1 disable;
alter trigger trigger_name2 disable;
alter trigger trigger_name3 disable;
alter trigger trigger_name4 disable;
alter trigger trigger_name4 disable;
perl的解决方案

perl -pe 's/ORA-\d/\n$&/g' <oldfile >newfile
perl-pe的/ORA-\d/\n$&/g'新文件

要在序列ORA之前添加一个换行符-后跟一个数字(\d)

我可以通过以下方法实现:

SQL=$(echo "$SQL" | sed -e 's/ERROR/\\n\rERROR/g')

echo $SQL