2017-06-22 109 views
0

当我通过shell脚本执行DB查询只得到价值我得到以下输出需要从输出

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

你有轻微的改变命令。

<sql-command>|sed -n '/CURRENTCOUNT/{n;n;p}' 
      1182870 
0

the-sql-command | grep -A 2 '^SUM(SUM' | tail -n 1 | grep -o '[0-9]*'