当前位置: 技术问答>linux和unix
新手请教一段AWK代码,报错。
来源: 互联网 发布时间:2016-03-22
本文导语: BEGIN{record="123#456#789"; split(record,myArray,"#")} END {for (i in myArray) {print myArray(i)}} 运行时报错。错误如下: [root@localhost vipshaw]# ./array_test.awk ./array_test.awk: line 1: BEGIN{record=123#456#789: command not found ./array_test.awk: line...
BEGIN{record="123#456#789";
split(record,myArray,"#")}
END {for (i in myArray) {print myArray(i)}}
运行时报错。错误如下:
[root@localhost vipshaw]# ./array_test.awk
./array_test.awk: line 1: BEGIN{record=123#456#789: command not found
./array_test.awk: line 2: syntax error near unexpected token `record,myArray,"#"'
./array_test.awk: line 2: `split(record,myArray,"#")}'
但怎么看也看不出错,请大家帮我看看。
split(record,myArray,"#")}
END {for (i in myArray) {print myArray(i)}}
运行时报错。错误如下:
[root@localhost vipshaw]# ./array_test.awk
./array_test.awk: line 1: BEGIN{record=123#456#789: command not found
./array_test.awk: line 2: syntax error near unexpected token `record,myArray,"#"'
./array_test.awk: line 2: `split(record,myArray,"#")}'
但怎么看也看不出错,请大家帮我看看。
|
./array_test.awk
文件里面追加第一行#!/bin/awk
指定awk来处理后面的代码
文件里面追加第一行#!/bin/awk
指定awk来处理后面的代码