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/PASSWRD@服务名
#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' //|//| ' 'a[$17""$30""$50]++' Exp_IDS_riskcon.EXF | head -1
#列表指定项目下的JOB清单
dsjob -ljobs P05_EDW