chkdict
来自「ksh 实现的基于hpux下的性能数据以及故障的采集程序。可以作为新手练手使用」· 代码 · 共 70 行
TXT
70 行
#!/bin/kshDictDir=$HOME/hpux/dictDictFile=dict.dat[[ ${#1} > 0 ]] && DictFile=$1rm -f ${DictDir}/dict.tmpawk ' length($0) > 0 && $1!~/^#/ { print $1, tolower($2),tolower($3);}' ${DictDir}/${DictFile} > ${DictDir}/dict.tmpfor i in 1 2 3do if [[ $i = 1 ]] then echo " 检查中文名称" comment=" 检查中文名称" elif [[ $i = 2 ]] then echo " 检查英文名称" comment=" 检查英文名称" else echo " 检查数据类型" comment=" 检查数据类型" fi awk -v cout=$i ' BEGIN { nubr=0; } { print $'"$i"'; if ( cout == 3 ){ type = $'"$i"'; if( type != "char" && type != "smallint" && type != "int" && type != "dec" && type != "date" ){ nubr++; print $0 " 数据类型 " $3 " 不合法,应为 int smallint dec date char 之一" > "/dev/stderr"; } } } END { if ( cout == 3 && nubr == 0 ){ print " 所有字段数据类型都合法" > "/dev/stderr"; } }' ${DictDir}/dict.tmp > ${DictDir}/a if [[ $i = "3" ]] then break fi sort ${DictDir}/a >${DictDir}/b uniq -c ${DictDir}/b >${DictDir}/c awk ' BEGIN { cout=0; label=0; } $1 > 1 { print; cout++; } END { if( cout == 0 ){ print "'"$comment"',无重复值"; } } ' ${DictDir}/cdonerm -f ${DictDir}/a ${DictDir}/b ${DictDir}/c
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?