当我通过shell脚本执行数据库查询时,我得到以下输出
SQL*Plus: Release 10.2.0.5.0 - Production on Thu Jun 22 02:50:47 2017
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
SQL>
SUM(SUM(CURRENTCOUNT))
----------------------
1182870
SQL> Disconnected from Oracle Database 10g Release 10.2.0.5.0 - 64bit Production
我需要使用sed
删除其中的其他内容并仅获取1182870
sed -n '/COUNT(\*)/{n;n;p}'
答案 0 :(得分:1)
要在 sqlplus 报告中禁止显示列标题,请输入:
SET HEADING OFF
https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12040.htm#i2699001
答案 1 :(得分:0)
您的命令稍作修改。
<sql-command>|sed -n '/CURRENTCOUNT/{n;n;p}'
1182870
答案 2 :(得分:0)
the-sql-command | grep -A 2 '^SUM(SUM' | tail -n 1 | grep -o '[0-9]*'