⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 deleteattr.sh

📁 一个awk和bsh混合编程的例子
💻 SH
字号:
#!/bin/kshVERSION=V51DREPORT_ID=10CONFIG_FILE_NAME="Rep_$VERSION.cfg";attrIdList=$1;delRedundance(){	if [ -z "$VERSION" ]; then   		echo "ERROR: version is not specified.";   		exit 1;	fi   	if [ -z "$REPORT_ID" ]; then		echo "ERROR: report_id is not specified.";		exit 1;	fi		if [ ! -r $CONFIG_FILE_NAME ]; then		echo "ERROR: $CONFIG_FILE_NAME not exist.";		exit 1;	fi		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":" '		/^ *\t* *#.*/ {;}		/^ *\t* *$/ {;}		/^[0-9]*/ {			if ($1==id ){					printf "%s\n",$3;			}		}' id=$REPORT_ID $CONFIG_FILE_NAME`;	}	fi		attrIdList_BAK=$attrIdList;	attrIdList_BAK_TMP=${attrIdList_BAK#*\{};	attrIdList_BAK=${attrIdList_BAK_TMP%*\}};		attr_orig_array=`echo $attrIdList_BAK|awk -F":" '{		for (ix=1; ix <=NF; ix+=1){			printf "%s\n", $ix;		}	}'`;		attrs_String="";	for elem in $attr_orig_array 	do		found=0;		for attr in $Attr_Names 		do			if [ "$attr" = "$elem" ]; then				found=1;				break;			fi		done		if [ found -eq 0 ]; then			attrs_String=$attrs_String":"$elem;		fi	done	attrIdList_TMP=${attrs_String#*:};	attrIdList="{"$attrIdList_TMP"}";}delRedundance;for attr in $Attr_Names do	echo $attrdoneecho "-------------------"echo $attrIdList;

⌨️ 快捷键说明

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