chmod +x p_welltool_place.sh //為目前使用者添權重限
awk -F"||" '{ print NF }' $filename //檢查抽數結果
sed "s/^M//g" chap1 >chap1.new 在外部替換檔案内部字元串
%s/^M/SSS/g 在内部替換
#
ls /EDWETL/SH/EDW_TotalData/CIBS | while read Tfilename
do
filename=`echo $Tfilename | awk -F"." '{ print $1 }'`
echo $filename
mv /EDWETL/SH/EDW_TotalData/CIBS/$Tfilename /EDWETL/SH/EDW_TotalData/CIBS/$filename.sh
done
#指令回退
ESC+K =>up;ESC+J=>down
//informix連接配接資料庫 執行SQL語句
dbschema -d qcx2000_1010100 -t all QCX.sql
dbaccess dw_corp -<<! > /dev/null 2>&1
#批量修改檔案字尾名
ls *.sh.tmp | sed -e 's/.*/mv & &/' -e 's/sh.tmp$/sh/' | sh
"
ctrl + "/" ##退出>輸入模式
##搜尋目前目錄所有檔案中包含 a的内容
grep "a" / *.*>> a.txt
#&& 和 ||
其作用是使管道線有條件地執行。其使用方法為:
command1 && command2:當且僅當command1執行成功後才執行command2
command1 || command2:當且僅當command1執行失敗後才執行command2
#informix 查詢日期字段
select
fh_time,
hp_time
from hp_list
where to_char(fh_time, "%Y%m%d%R") like '%:%'
or to_char(hp_time, "%Y%m%d%R") like '%:%'
select
lr_date,
xh_date,
tb_date,
qd_date,
hb_date,
data_time
from policy_f
where length(substr(to_char(lr_date, "%Y%m%d%R"),9,length(to_char(lr_date, "%Y%m%d%R")))) > 3
sed -n '/hhold2002_5010100/p' tablecheck.log > tttttttt.tmp
#強制複制檔案
cp -f /EDWETL/SH/kangji/table/tmpdir/1020100/01/ex_policy.stu /EDWETL/SH/kangji/table/tmpdir/3080100/01/
#列印從Steve 到 Jennifer之間的行
sed -n '/Steve/,/Jennifer/p' sedfile.txt
#多重編輯 第一重删除1到3行 第二重将aaaa替換成ddd
sed -e '1,3d' -e 's/aaaa/ddd/' sedfile.txt
#指定目錄搜尋所有檔案裡的指定字元
find /EDWETL/SH/EDW/ -type f -print | xargs grep "/$6" >> /EDWETL/SH/kkkkkkkkkkkkkkkkkkkkkkkkkkkkkk.tmp
#指定目錄搜尋所有檔案裡的指定字元
grep "石樓-廣州" *
#修改stu字尾名
ls *.stu | sed -e 's/.*/mv & &/' -e 's/stu$/ini/' | sh
nohup
#查找大于0位元組的檔案
find . -size +0c -print
# FS 設定輸入域分隔符,等價于指令行- F選項
# RS 控制記錄分隔符
# NF 浏覽記錄的域個數
# NR 已讀的記錄數
#
#
#
# ARGC 指令行參數個數
# ARGV 指令行參數排列
# ENVIRON 支援隊列中系統環境變量的使用
# FILENAME awk浏覽的檔案名
# FNR 浏覽檔案的記錄數
# OFS 輸出域分隔符
# ORS 輸出記錄分隔符
#
# 表12:test 指令的常用參數
# 檔案測試
# -d name 測試name 是否為一個目錄
# -f name 測試name 是否為普通檔案
# -L name 測試name 是否為符号連結
# -r name 測試name 檔案是否存在且為可讀
# -w name 測試name 檔案是否存在且為可寫
# -x name 測試name 檔案是否存在且為可執行
# -s name 測試name 檔案是否存在且其長度不為0
# f1 -nt f2 測試f1 是否比f2 更新
# f1 -ot f2 測試f1 是否比f2 更舊
# 字元串測試
# s1 = s2 測試兩個字元串的内容是否完全一樣
# s1 != s2 測試兩個字元串的内容是否有差異
# -z s1 測試s1 字元串的長度是否為0
# -n s1 測試s1 字元串的長度是否不為0
# 整數測試
# a -eq b 測試a 與b 是否相等
# a -ne b 測試a 與b 是否不相等
# a -gt b 測試a 是否大于b
# a -ge b 測試a 是否大于等于b
# a -lt b 測試a 是否小于b
# a -le b 測試a 是否小于等于b
# 組合與否定測試
# t1 -a t2 AND(交集):當t1 與t2 條件同時成立時,才算成立
# t1 -o t2 OR(并集):隻要t1 或t2 任一條件成立,就算成立
# ! your_test 否定測試:當your_test 失敗時,則條件成立
# /( your_test /) 改變運算順序(與代數一樣)
#
ps -f -l -ujim,jane,p05rpt
echo ". ~p05rpt/.profile;/EDWETL/SH/EDWContrl.sh " | at 02:00 tomorrow
echo ". ~p05rpt/.profile;/EDWETL/SH/EDW_TotalData/p07/P07_INC1.sh " | at 06:00 today
#列出目前計劃任務
at -l
#查詢空行
grep -c "^$" Exp_AutoClaim_c_taskaudit.tmp1
grep -c "spool off;//n!" Exp_AutoClaim_c_taskaudit.tmp1
#在指定目錄查詢指定檔案
find /EDWETL/SH/EDW/ -name "/EDWETL" -exec ls -l {} /;
find /backup -name "p07" | xargs ls -l
#在指定目錄查詢指定檔案
find /EDWETL/SH/EDW_TotalData/ -name "rownum.sh" -ok rm {} /;
#顯示指定IP登陸LOG
last -n 2000 | sed -n -e '/pts/p' | grep '10.202.1.77' > /EDWETL/SH/kangji/rizhi.log
#指定檔案夾大小
du -gs /ods/kangji/
#顯示登陸使用者程序資訊
ps -e -f | grep "p05rpt"
#查找EDW目錄 忽略txt2EXF目錄 下所有LOG檔案
find /EDWETL/SH/EDW/ -name txt2EXF -prune -o -name "*.log" -print
find /EDWETL/SH/EDW -newer test.tmp -name txt2EXF -prune -o -name State -prune -o -name LOG -prune -o -name CFG -prune -o -print -exec ls -l {} /;
#壓縮檔案
tar -cvf - 20070811 | gzip -qc > /backup/EDW/P07_20070811.tar.gz
#解壓縮
gunzip 20070610.tar.gz
tar -xvf 20070610.tar
#檢視系統硬體資訊
vmstat
#設定指令行為VI模式
set -o vi
#關於 bash shell 在處理 command line 時的順序說明
alias, function, builtin command, external command
# diff 有三種顯示格式 : normal, context, unified
#
# 你這裡的是 normal (符合 POSIX 标準):
#
# normal 有三種提示
#
# a - add
# c - change
# d - delete
#
# lar - Add the lines in range r of the second file after line l of
# the first file. For example, 8a12,15 means append lines 12-15
# of file 2 after line 8 of file 1; or, if changing file 2 into file 1,
# delete lines 12-15 of file 2.
#
# fct - Change the lines in range f of the first file with lines in
# range t of the second file. This is like a combined add and
# delete, but more compact. For example, 5,7c8,10 means
# change lines 5-7 of file 1 to read as lines 8-10 of file 2; or, if
# changing file 2 into file 1, change lines 8-10 of file 2 to read as
# lines 5-7 of file 1.
#
# rdl - Delete the lines in range r from the first file; line l is where
# they would have appeared in the second file had they
# not been deleted. For example, 5,7d3 means delete lines 5-7
# of file 1; or, if changing file 2 into file 1, append lines 5-7 of file
# 1 after line 3 of file 2.
diff -s /backup/EDWINC/20070707 /backup/EDWINC/20070708 | egrep -v '(/<|/>)'
find /EDWETL/SH/ -newer break1.awk ! -newer break.awk | xargs ls -l | awk '$6 ~/Aug/'
#查重複記錄
awk -F"||" '{ print $2,$3,$4}' /backup/EDW/AUTO/3010100/Exp_Auto_T_VEHSERDM.EXF |sort -k1
#背景運作SH
nohup P07_INC.sh > p07.log 2>&1
#保留小數點
SELECT
TRUNC(to_number(ACT_COST_AMOUNT),2)
FROM CUX_ABM_COST_ACCT_T
#AWK簡寫
awk -F"||" '$1~/4547/ && $2~/802817/' Exp_P07_Financial_Budget_rcfyys*
#分解字元串
echo 20030922|sed 's//(..../)/(../)/(../)//1 /2 /3/'|read year month day
#将資料檔案中的每個詞的第一個字母變成大寫
awk -f /EDWETL/SH/kangji/tmp.awk /EDWETL/SH/kangji/tmp/tmp.tmp
BEGIN{
FS=":"
}
{
for(i=1;i<=NF;i++){
first=substr($i,1,1);
sub(/^./,toupper(first),$i);
printf "%s",$i;
if(i<NF)
{printf ":"}
}
printf "/n"
}
#ORACLE去回車與換行符
REPLACE(REPLACE(BZDM,CHR(10),''),CHR(13),'') AS BZDM
#awk比較檔案
awk 'NR==FNR{a[$0]++}NR>FNR{if(!($0 in a)) print}' Exp_Cibs_p_cargo.EXF /backup/cibs_package/Exp_Cibs_p_cargo.EXF > tmp
# 12. NR 和 FNR 有何差別?
#
# A: NR 已經讀取過的記錄數。
# FNR 從目前檔案中讀出的記錄數。
# 如果你隻處理一個檔案,則NR 和FNR 的值是一樣的。但如果是多個檔案, NR是對所有
# 的檔案來說的,而FNR 則隻是針對目前檔案而言。
# 11. 各種 shell 的 array size 有何限制?
#
# A:數組的下标最大限制是13088個,否則會因為存儲錯誤導緻系統崩潰
# 檢視目前用戶端環境
select
SYS_CONTEXT('USERENV','TERMINAL') terminal,
SYS_CONTEXT('USERENV','LANGUAGE') language,
SYS_CONTEXT('USERENV','SESSIONID') sessionid,
SYS_CONTEXT('USERENV','INSTANCE') instance,
SYS_CONTEXT('USERENV','ENTRYID') entryid,
SYS_CONTEXT('USERENV','ISDBA') isdba,
SYS_CONTEXT('USERENV','NLS_TERRITORY') nls_territory,
SYS_CONTEXT('USERENV','NLS_CURRENCY') nls_currency,
SYS_CONTEXT('USERENV','NLS_CALENDAR') nls_calendar,
SYS_CONTEXT('USERENV','NLS_DATE_FORMAT') nls_date_format,
SYS_CONTEXT('USERENV','NLS_DATE_LANGUAGE') nls_date_language,
SYS_CONTEXT('USERENV','NLS_SORT') nls_sort,
SYS_CONTEXT('USERENV','CURRENT_USER') current_user,
SYS_CONTEXT('USERENV','CURRENT_USERID') current_userid,
SYS_CONTEXT('USERENV','SESSION_USER') session_user,
SYS_CONTEXT('USERENV','SESSION_USERID') session_userid,
SYS_CONTEXT('USERENV','PROXY_USER') proxy_user,
SYS_CONTEXT('USERENV','PROXY_USERID') proxy_userid,
SYS_CONTEXT('USERENV','DB_DOMAIN') db_domain,
SYS_CONTEXT('USERENV','DB_NAME') db_name,
SYS_CONTEXT('USERENV','HOST') host,
SYS_CONTEXT('USERENV','OS_USER') os_user,
SYS_CONTEXT('USERENV','EXTERNAL_NAME') external_name,
SYS_CONTEXT('USERENV','IP_ADDRESS') ip_address,
SYS_CONTEXT('USERENV','NETWORK_PROTOCOL') network_protocol,
SYS_CONTEXT('USERENV','BG_JOB_ID') bg_job_id,
SYS_CONTEXT('USERENV','FG_JOB_ID') fg_job_id,
SYS_CONTEXT('USERENV','AUTHENTICATION_TYPE') authentication_type,
SYS_CONTEXT('USERENV','AUTHENTICATION_DATA') authentication_data
from dual
# 根據用戶端語言環境顯示不同的語言版本
select
*
from
FND_FLEX_VALUES_TL T, FND_FLEX_VALUES B
where
B.FLEX_VALUE_ID = T.FLEX_VALUE_ID
and T.LANGUAGE = userenv('LANG')
sqlplus USERNAME/[email protected]服務名
#FTP指令1
ftp 10.201.64.13
prompt
cd /backup/IDS_Total
mput
#FTP指令2
ftp -i -v -n 10.201.64.13
user p05rpt p05rpt
cd /backup/IDS_Total
mput *.gz
bye
#判斷重複
awk -F'