0

我的 awk 脚本中有函数来解析包含某些单词/字符的行

function tohyphen (o) {
        split ($0,a,"to[-_]")
        split (a[2],b,"-")
        k=b[1]
        p=b[2]
        return k
}

function tospace (o) {
        split ($0,a,"to ")
        split (a[2],b,"-")
        k=b[1]
        p=b[2]
        return k
}

funtion pipe (o) {
        split ($0,a,"|")
        split (a[2],b,"-")
        x=b[1]
        y=b[2]
        return x
        #return x
}
{
#if (match ($0, /to[-_]/))
if ($0 ~ /to[-_]/)
        print "found to- for interface ", $1, " is ", tohyphen($0), "is ",p, " is ", $1="",$0

else if ($0 ~ /to /)
        #(match ($0, /to /))
        print "found to  for interface", $1, " is ", tospace($0), "  is ", p, " is ", $1="",$0
else if ($0 ~ /\|/)
#       pipe($0)
        print "found to  for interface", $1, " is ",topipe($0), "  is ", y, " is ", $1="",$0
else
        print $1, $1="",$0
}

在仅搜索匹配以进行管道传输的第三个函数中,它不允许我返回任何内容,这给了我错误返回在函数之外。任何想法可能是什么问题或任何其他方式让我运行它。

4

1 回答 1

0

尝试正确的拼写功能!你有功能没有功能。您是否使用带有语法高亮的编辑器awk?您可以从 stackoverflows 标记中看到,功能不是保留字。

于 2013-05-30T11:58:38.367 回答