Note the sqlplus directives which will remove all unwanted output from the resulting file /tmp/count_options.out
su - oracle <<! echo " set lines 10 set pages 0 set trimspool on set verify off set heading off set feedback off set echo off spool /tmp/count_options.out SELECT TRIM(COUNT(*)) FROM DBA_REGISTRY; " > /tmp/count_options.sql sqlplus -s / as sysdba @/tmp/count_options.sql !Output is:
/tmp]# cat count_options.out 4Note that without the TRIM function, the output will be
/tmp]# cat count_options.out 4The -s switch will execute sqlplus silently, without it, the output would be
cat count_options.out 4 SYS@mydb01>SQL>
No comments:
Post a Comment