EOF中的$符號不被當成預設的跳脫字元需改成\$

dbhelper發表於2015-01-28
<



Shell中重定向<


1.EOF也可以換成其他任意的字元,大小寫不論,只要成對出現即可
2. 第二個EOF必須頂格寫,否則會報錯。
3. EOF中如果帶有 $變數的時候會將$和變數名變成空格


如果不希望EOF中的$符號不希望被當成預設的跳脫字元需改成\$




sqlplus -S  /nolog <
connect / as sysdba;
set heading off;
set feedback off;
set echo off;
set pagesize 800;
set line  450;
set echo off;
set veri off;
spool /tmp/status.log;
select decode(status,'OPEN',0,2) "status" from v\$instance;
spool off;
exit;
EOF










======================問題:=====================================================         
[oracle@ORACLE-master ~]$ 
[oracle@ORACLE-master ~]$ sqlplus -S  /nolog <
> connect / as sysdba;
> set heading off;
> set feedback off;
> set echo off;
> set pagesize 800;
> set line  450;
> set echo off;
> set veri off;
> spool /tmp/status.log;
> select decode(status,'OPEN',0,2) "status" from v$instance;
> spool off;
> exit;
> EOF
select decode(status,'OPEN',0,2) "status" from v
                                               *
ERROR at line 1:
ORA-00942: table or view does not exist




[oracle@ORACLE-master ~]$ 








==============正確=========================================


[oracle@ORACLE-master ~]$ sqlplus -S  /nolog <
> connect / as sysdba;
> set heading off;
> set feedback off;
> set echo off;
> set pagesize 800;
> set line  450;
> set echo off;
> set veri off;
> spool /tmp/status.log;
> select decode(status,'OPEN',0,2) "status" from v\$instance;
> spool off;
> exit;
> EOF


         0
         

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8494287/viewspace-1418058/,如需轉載,請註明出處,否則將追究法律責任。

相關文章