shell指令碼執行

2022-06-03 01:57:15 字數 1343 閱讀 7828

最近工作特別忙,感覺好長時間沒有寫日誌了,今天就來簡單的聊一下linux系統中的shell指令碼。其實簡單來說就是shell程式設計就是對一堆linux命令的邏輯化處理,在指令碼裡編輯所要執行的業務邏輯。

#!/bin/bash

#modify below variables if you need.

user=oracle                     ----資料庫的使用者名稱

hottime='2020-08-28 0:01:00'            -----開始的時間

#do not modify below variables.

oracle_uid=`awk -f : '/oracle/ ' /etc/passwd`

if [ `id -u` -ne $oracle_uid ];then

echo 'use oracle account to run this scripts!'

exit 1

fisqlplus -s / as sysdba <>/dev/null

set pages 0

set feedback off

set long 99999

spool /tmp/fulltext.txt

select sql_fulltext

from v\$sqlarea

where parsing_schema_name = '$user'

and last_load_time >

to_date('$hottime', 'yyyy-mm-dd hh24:mi:ss');

spool off

spool /tmp/aobjs.txt

select object_name from dba_objects where object_type = 'table' and owner = '$user';

spool off

exit

eofhot=$(cat /tmp/fulltext.txt|egrep -oi $(str1=""; for i in `cat /tmp/aobjs.txt` ;do str1=$str1"|"$i;done ;echo $str1)|tr a-z a-z|sort|uniq|wc -l)

aobjs=`cat /tmp/aobjs.txt|wc -l`

echo "scale=2;$hot/$aobjs"|bc

#clean

rm -rf /tmp/aobjs.txt /tmp/fulltext.txt     ---儲存退出

接著還沒有完  就是給這個檔案新增可執行的許可權   chmod +x test.sh

最後執行  ./test.sh就可以了。

shell 執行shell指令碼

bin bash echo hello world 是乙個約定的標記,它告訴系統這個指令碼需要什麼直譯器來執行,即使用哪一種 shell。echo 命令用於向視窗輸出文字。1 作為可執行程式 chmod x test.sh 使指令碼具有執行許可權 test.sh 執行指令碼注意,一定要寫成 test...

Shell指令碼執行

shell是乙個命令列直譯器,它為使用者提供了乙個向linux核心傳送請求以便執行程式的介面系統級程式,使用者可以用shell來啟動 掛起 停止甚至是編寫一些程式。shell指令碼 shell script 是一種shell編寫的指令碼程式。linux的shell種類很多,常見的有 bourne a...

ios 執行shell指令碼

一 由於ios中沒有 cocoa的nstask 所以要在cocoa touch sdk中執行shell 只能用系統呼叫 int system const char string 例如 system ls 注意system是系統c函式 所以引數不要使用nsstring 函式庫 include syst...