English 中文(简体)
awk syntax误差
原标题:awk syntax error
  • 时间:2012-04-25 01:01:58
  •  标签:
  • awk

我拿着我的手法来犯了这一yn语错误——我试图在各地,但无uck。 任何人都可以得到帮助。 感谢!

awk: non-terminated string  | grep Re... at source line 1
 context is
     >>>  <<< 
awk: giving up
 source line number 2
awk  / (TCP|UDP) / { split($5, addr, /:/); 
cmd = "/bin/geoiplookup " addr[1] | grep  Rev 1:  | sed  s/Rev 1: //g  " | awk -F ,    {print $4",", $3",", $2} ; 
cmd | getline rslt; 
close(cmd); 
print $1, $2, $3, $4, $5, $6, rslt }  < "$IP_PARSED" >> "$BlockedIPs"
最佳回答

我认为,我们早就来到这里。 Don t试图在cmd内进行复杂的处理。 之后,利用这一设施管理外部指挥,在主要的科索沃信托公司方案内进行处理。

awk  / (TCP|UDP) / { split($5, addr, /:/); 
cmd = "/bin/geoiplookup " addr[1] ; 
while (cmd | getline rslt) {
    if (rslt ~ /Rev 1: /) {
        gsub(/Rev 1: /, "", rslt)
        split(rslt, r, ",")
    }
}
close(cmd); 
print $1, $2, $3, $4, $5, $6, r[4], r[3], r[2] }  < "$IP_PARSED" >> "$BlockedIPs"
问题回答

<代码>wk的论点已终止。 <代码>awk正在解释你的管道的其余部分,并引起混乱。 如果您实际上打算将管道作为你手稿的一部分,则考虑将awk的文字写成文档(删除单一引文),或用双字母取代你最外的单一报价,并使用<>>>>。 不幸的是,你不能说一字。

你们正试图将单一字句放在单一字体内。 这并不奏效;此外,炮弹无法轻易掩饰。 有一些复杂的方法,例如:

$ echo  hello " " world 
hello world
$ echo  hello   world 
hello world

Note: embedding does not work, as the equivalent does with double quotes.

$ echo  hello world 
hello world




相关问题
awk save command ouput to variable

I need to execute a command per line of some file. For example: file1.txt 100 4 file2.txt 19 8 So my awk script need to execute something like command $1 $2 $3 and save the output of command $1 $2 ...

awk and bash script

I have a tgz file which contains a version file, version.txt. This file has only one line "version=1.0.0". This tgz file is present in two different directories and has the same name. My requirement ...

awk - how to specify field separator as binary value 0x1

Is it possible to specify the separator field FS in binary for awk? I have data file with ascii data fields but separated by binary delimiter 0x1. If it was character 1 it would look like this: ...

Awk - print next record following matched record

I m trying to get a next field after matching field using awk. Is there an option to do that or do I need to scan the record into array then check each field in array and print the one after that? ...

Using Unix Tools to Extract String Values

I wrote a small Perl script to extract all the values from a JSON formatted string for a given key name (shown below). So, if I set a command line switch for the Perl script to id, then it would ...

how to use sed, awk, or gawk to print only what is matched?

I see lots of examples and man pages on how to do things like search-and-replace using sed, awk, or gawk. But in my case, I have a regular expression that I want to run against a text file to extract ...

Bulk Insert Code Before </body> Tag in 100 Files

I d like to insert <?php include_once( google_analytics.php ); ?> before the closing body tag of about 100 php files. Unfortunately the person who made the site didn t make a header or ...