shell变量定义中的特殊符号
今天要写一个shell语句来输出数据库的v$database的信息
定义bb为一个接收sql返回值的变量
需要注意的是: select * from v$database ; 语句
由于其中用到了$符号,所以执行的时候肯定会报错,因为无法识别,需要在$的前面加上转义符\\即可,如下所示:
vi t.sh #/bin/bash bb=` kdsql -s sys/kdb <<AAA set feedback off set linesize 140 set heading off col "Instance Name" format a15 col "Database Name" format a15 col "Version" format a20 col "Status" format a12 col "NLS Character" format a20 col "Log Mode" format a13 col "DB Create Time" format a20 col "DB Uptime" format a15 select * from v\\$database ; AAA` echo $bb ./t.sh 817954975 fs 2017/04/18 1059052 READ WRITE 0 0 ARCHIVELOG 1021594 2017/05/03
如有意见或建议,欢迎评论,共同学习!