com.sh

来自「一个awk和bsh混合编程的例子」· Shell 代码 · 共 59 行

SH
59
字号
VERSION=51CREPORT_ID=21CONFIG_FILE_NAME="Rep_$VERSION.cfg";#Attr_Names--attribute names;#Attr_Types--attribute types;#Obj_Deleted--0:object is not deleted;1:object is deletedparseConf(){	Obj_Deleted=`awk -F":" '			BEGIN {deleted=0;}		/^ *\t* *#.*/ {;}		/^ *\t* *$/ {;}		/^[0-9]*/ {			if ($1==id ){				if (length($3)==0 ){					deleted=1;				}			}		}		END {printf "%d\n",deleted;}' id=$REPORT_ID $CONFIG_FILE_NAME`;		if [ $Obj_Deleted -eq 0 ]; then	{		Attr_Names=`awk -F":" '		BEGIN{attr_ix=0; printf "{"}		/^ *\t* *#.*/ {;}		/^ *\t* *$/ {;}		/^[0-9]*/ {			if ($1==id ){				if (attr_ix==0){					printf "%s",$3;				}				else{					printf ":%s",$3;				}				attr_ix+=1;			}		}		END {printf "}\n";}' id=$REPORT_ID $CONFIG_FILE_NAME`;	}	fi}aaa="aaaaaaa";bbb="bbbbbbbb";ccc="cccccccc";ddd=$aaa":"$bbb":"$ccc;echo $ddd;parseConf;echo $Attr_Namesif [ "$Attr_Names"="{}" ];then	echo "empty";fi

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?