awk函数不允许返回

awk函数不允许返回,awk,gawk,Awk,Gawk,我的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]

我的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
}
在第三个函数中,它只搜索与管道匹配的内容,不允许我返回任何内容,返回的错误在函数之外。
你知道问题出在哪里吗?或者我可以用其他方式运行它。

请正确拼写函数!你有功能,没有功能。您是否正在使用带有语法突出显示的编辑器来显示
awk
?您可以从stackoverflows标记中看到funtion不是保留字

非常感谢你,我为此打了自己一巴掌,花了这么长时间才想出如何编写这个脚本,我没有看到这么基本的东西。我使用nano来做这个,但它没有突出显示函数关键字你应该使用emacs或vi来编辑源文件,这会使你的生活更轻松,你会更快地调试这些问题。你应该通过点击旁边的勾号来接受这个答案,以显示你的问题已经解决。勾号标记,再次感谢这是我关于stackoverflow的第一个问题,是的,我想我下一步要读的是vi教程。