求助,在SunOS中的awk的使用问题.
我有一段如下代码在SUSE10中正常使用通过.awk '/\/{$0="\n<ERROR "++p">\n"$0}/.\wException/&&($0!~/ERROR/){$0="\n<Exception "++P">\n"$0}1' temp.log但是在SunOS中则提示语法错误,还请高手指点.以前没接触过Solaris,对这边不熟悉.root@T5220210161 # awk '/\/{$0="\n<ERROR "++p">\n"$0}/.\wException/&&($0!~/ERROR/){$0="\n<Exception "++P">\n"$0}1' temp.log
awk: syntax error near line 1
awk: bailing out near line 1
root@T5220210161 # uname -a
SunOS T5220210161 5.10 Generic_142900-14 sun4v sparc SUNW,SPARC-Enterprise-T5220
root@T5220210161 # man awk
Reformatting page.Please Wait... done
User Commands awk(1)
NAME
awk - pattern scanning and processing language
SYNOPSIS
/usr/bin/awk [-f progfile] [-Fc] [ 'prog']
/usr/xpg4/bin/awk[-FcERE] [-v assignment...] 'program'
-f progfile...
DESCRIPTION
The /usr/xpg4/bin/awk utility is describedonthenawk(1)
manual page.
The /usr/bin/awk utility scans each input filename for lines
thatmatchany of a set of patterns specified in prog. The
prog string must be enclosed in single quotes ( ')topro-
tectitfrom the shell. For each pattern in prog there can
be an associated action performed when a line of afilename
matchesthepattern.The set of pattern-action statements
can appear literally as prog or in a file specified with the
-fprogfile option. Input files are read in order; if there
are no files, the standard input is read. The file name'-'
means the standard input.
OPTIONS
The following options are supported:
-f progfile awk uses the set of patterns itreadsfrom
progfile.
-Fc Uses the character c as the fieldseparator
(FS)character. Seethe discussion of FS
below.
USAGE
Input Lines
Each input line is matched against thepatternportionof
everypattern-actionstatement;theassociated action is
performed for each matched pattern. Any filename of the form
var=valueistreated as an assignment, not a filename, and
is executed at the time it would have been opened if it were
a filename. Variables assigned in this manner are not avail-
able inside a BEGIN rule, and are assigned afterpreviously
specified files have been read.
An input line is normally made upoffieldsseparatedby
whitespaces.(This default can be changed by using the FS
SunOS 5.10 Last change: 22 Jun 2005 1
:sleepy: 没人回答哦...我自己解决啦...
使用nawk替换awk就可以了. :em27: 厉害
页:
[1]