📄 chkalias
字号:
#!/bin/ksh#@(#) dfgj # 用法: chkuniq 别名文件 [字典文件] 默认字典文件为 $HOME/dict/dict.datfunction fchkalias { TmpFile=$HOME/dict/alias.tmp TmpUniq=$HOME/dict/uniq.tmp TmpSort=$HOME/dict/sort.tmp [[ ${#1} = 0 ]] && ChkFile=$HOME/dict/alias.dat [[ ${#1} = 0 ]] || ChkFile=$HOME/dict/$1 [[ ${#2} = 0 ]] && DictFile=$HOME/dict/dict.dat [[ ${#2} = 0 ]] || DictFile=$2 while read -r f1 f2 do [[ ${#f1} = 0 ]] && continue if [[ `expr "$f2" : '[a-zA-Z0-9_.]*' ` != ${#f2} ]] then echo "#2 文件 $ChkFile 中第二个域不应是中文" return 2 fi findename $f1 $DictFile | read -r EnWord f2=`echo $f2 | tr "[:upper:]" "[:lower:]"` if [[ "$f2" = "$EnWord" ]] then echo "#3 $f1 $f2 与字典文件 $DictFile 中相同" return 3 fi done < $ChkFile awk ' length( $1 ) > 0 { print $1, tolower( $2 ); } ' $ChkFile > $TmpFile sort +1 +2 $TmpFile > $TmpSort uniq -c $TmpSort > $TmpUniq awk ' $1 > 1 { exit 9;}' $TmpUniq ret=$? if [[ $ret != 0 ]] then echo "#$ret 别名文件 $ChkFile 行重复" return $ret fi cut -f1 $TmpSort | uniq -c | awk ' $1 > 1 { exit 10;}' ret=$? if [[ $ret != 0 ]] then echo "#$ret 别名文件 $ChkFile 中文名称重复,请用 chkdict 检查" return $ret fi uniq $TmpSort > ${ChkFile} ret=$? echo "#$ret 别名文件 $ChkFile 检查成功" return 0}label=0if [[ ${#1} != 0 ]] then type=`basename $1` type=`expr "$type" : '.*\.\(.*\)$'` if [[ ${#type} = 0 ]] then echo " 文件名 $1 不合法, 合法文件名如 alias.KN" exit 2 fi while read f1 f2 f3 rest do if [[ ${#f1} = 0 || `expr "$f1" : '^#.*'` > 0 ]] then continue fi if [[ "$f2" = "$type" ]] then for word in $rest do if [[ `expr "$word" : '^dict.*'` > 0 ]] then dict=$word label=1 break fi done break fi done < $HOME/etc/txkind.dat echo dict is $dict if [[ $label = 0 ]] then echo " 没有找到 $1 对应的数据字典文件" exit 3 fi fchkalias $1 $dict | read -r mesgelse fchkalias | read -r mesgfiecho $mesg
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -