Reputation: 81
When I execute a DB query via shell script I get the following output
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
I need to use sed
to remove the other contents in it and get only 1182870
i used
sed -n '/COUNT(\*)/{n;n;p}'
Upvotes: 0
Views: 571
Reputation: 1225
To suppress the display of column headings in sqlplus report, enter:
SET HEADING OFF
https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12040.htm#i2699001
Upvotes: 1
Reputation: 410
the-sql-command | grep -A 2 '^SUM(SUM' | tail -n 1 | grep -o '[0-9]*'
Upvotes: 0
Reputation: 18411
Your command with minor changes.
<sql-command>|sed -n '/CURRENTCOUNT/{n;n;p}'
1182870
Upvotes: 0