[20180413]bash 位置引數.txt

lfree發表於2018-04-13

[20180413]bash 位置引數.txt

--//上午在測試hugepage時,連結http://blog.itpub.net/267265/viewspace-2152888/
--//指令碼寫的太不靈活,不應該每次測試修改指令碼,應該採用傳位置引數.

--//修改如下:
$ cat b.sh
#!/bin/bash
grep -i page /proc/meminfo
echo
for i in $(seq 100)
do
nohup sqlplus -s scott/book <<EOF > /dev/null 2>&1 &
variable a number;
exec :a := $1;
--//alter session set "_serial_direct_read"=never;
Select count(*) from t where 1=:a;
host sleep 10
commit;
quit;
EOF
done
echo sleep 5s
sleep 5
echo
grep -i page /proc/meminfo

---//寫一個例子測試如下:
$ cat b1.sh
#!/bin/bash
sqlplus  scott/book <<EOF
variable a number;
exec :a := $1;
Select count(*) from t where 1=:a;
commit;
quit;
EOF

$ . b1.sh 1
PL/SQL procedure successfully completed.
  COUNT(*)
----------
     64000
Commit complete.

$ . b1.sh 0

PL/SQL procedure successfully completed.
  COUNT(*)
----------
         0
Commit complete.

--//不知道當時如何想使用sqlplus &1.一下子思維沒有轉過來.空閒下來想一下,可以這樣寫,例子:

$ cat b1.sh
#!/bin/bash
sqlplus -s scott/book <<EOF @/dev/null $1
variable a number;
exec :a := &1;
Select count(*) from t where 1=:a;
commit;
quit;
EOF 1

$ . b1.sh 1
PL/SQL procedure successfully completed.
COUNT(*)
---------
64000
Commit complete.

$ . b1.sh 0
PL/SQL procedure successfully completed.
COUNT(*)
----------
0
Commit complete.

--//做一個記錄..

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

相關文章