求助,在SunOS中的awk的使用问题.
我有一段如下代码在SUSE10中正常使用通过.
- awk '/\[ERROR\]/{$0="\n<ERROR "++p">\n"$0}/.\wException/&&($0!~/ERROR/){$0="\n<Exception "++P">\n"$0}1' temp.log
复制代码但是在SunOS中则提示语法错误,还请高手指点.以前没接触过Solaris,对这边不熟悉.
- root@T5220210161 # awk '/\[ERROR\]/{$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 '] [parameters]
- [filename...]
- /usr/xpg4/bin/awk [-FcERE] [-v assignment...] 'program'
- -f progfile... [argument...]
- DESCRIPTION
- The /usr/xpg4/bin/awk utility is described on the nawk(1)
- manual page.
- The /usr/bin/awk utility scans each input filename for lines
- that match any of a set of patterns specified in prog. The
- prog string must be enclosed in single quotes ( ') to pro-
- tect it from the shell. For each pattern in prog there can
- be an associated action performed when a line of a filename
- matches the pattern. The set of pattern-action statements
- can appear literally as prog or in a file specified with the
- -f progfile 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 it reads from
- progfile.
- -Fc Uses the character c as the field separator
- (FS) character. See the discussion of FS
- below.
- USAGE
- Input Lines
- Each input line is matched against the pattern portion of
- every pattern-action statement; the associated action is
- performed for each matched pattern. Any filename of the form
- var=value is treated 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 after previously
- specified files have been read.
- An input line is normally made up of fields separated by
- white spaces. (This default can be changed by using the FS
- SunOS 5.10 Last change: 22 Jun 2005 1
复制代码
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没人回答哦...我自己解决啦...
使用nawk替换awk就可以了.
厉害