form.awk

来自「《PC数据采集》源代码」· AWK 代码 · 共 21 行

AWK
21
字号
# form.awk is an awk script that requires access to 2 files: The #first file is called "form.letter". This file contains the format #for a form letter. The awk script uses another file, "data.form", #as its input file. This file contains the information that will be #substituted into the form letters in the place of the numbers #preceded by pound signs. Today's date is substituted in the place #of "@date" in "form.letter".BEGIN{ FS=":"; n=1while(getline < "form.letter" >  0)    form[n++] = $0   #Store lines from form.letter in an array"date" | getline d; split(d, today, " ")    # Output of date is Sun Mar 2 14:35:50   PST 1999thisday=today[2]". "today[3]", "today[6]}{   for( i = 1; i < n; i++ ){	temp=form[i]	for ( j = 1; j <=NF; j++ ){	    gsub("@date", thisday, temp)	    gsub("#" j, $j , temp )	}	print temp    }}

⌨️ 快捷键说明

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