2017-06-22 111 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]*'