- 论坛徽章:
- 0
|
初学shell没多久, 对一些awk 里面的自定义函数不了解。请大侠帮忙分析以下自定义函数以及其实现的功能。
谢谢!
$AWK -v hostn="$HOSTNAME" -v pwusername="$userid" -v pwhome="$home" -v pwgecos="$gecos" -v outfile="$CSVFILE" -v sshtrace=$SSHTRACE -v debug=$DEBUG '
function quotify(input,output,c,i) {
output="\""
for (i=1;i<=length(input);i++) {
c=substr(input,i,1)
if (c == "\"") {
output=output "\""
}
output=output c
}
return output "\""
}
BEGIN {
dl=","
*
*
*
print quotify(hostn) dl quotify(pwusername) dl quotify(pwgecos) dl quotify(have_label) dl quotify(urt) dl >>outfile
}
'
|
|