免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2230 | 回复: 2
打印 上一主题 下一主题

求助,在SunOS中的awk的使用问题. [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-03-26 10:33 |只看该作者 |倒序浏览
我有一段如下代码在SUSE10中正常使用通过.
  1. awk '/\[ERROR\]/{$0="\n<ERROR "++p">\n"$0}/.\wException/&&($0!~/ERROR/){$0="\n<Exception "++P">\n"$0}1' temp.log
复制代码
但是在SunOS中则提示语法错误,还请高手指点.以前没接触过Solaris,对这边不熟悉.

  1. root@T5220210161 # awk '/\[ERROR\]/{$0="\n<ERROR "++p">\n"$0}/.\wException/&&($0!~/ERROR/){$0="\n<Exception "++P">\n"$0}1' temp.log
  2. awk: syntax error near line 1
  3. awk: bailing out near line 1

  4. root@T5220210161 # uname -a
  5. SunOS T5220210161 5.10 Generic_142900-14 sun4v sparc SUNW,SPARC-Enterprise-T5220


  6. root@T5220210161 # man awk
  7. Reformatting page.  Please Wait... done

  8. User Commands                                              awk(1)

  9. NAME
  10.      awk - pattern scanning and processing language

  11. SYNOPSIS
  12.      /usr/bin/awk [-f progfile] [-Fc] [ '  prog  ']  [parameters]
  13.      [filename...]

  14.      /usr/xpg4/bin/awk  [-FcERE]   [-v assignment...]   'program'
  15.      -f progfile... [argument...]

  16. DESCRIPTION
  17.      The /usr/xpg4/bin/awk utility is described  on  the  nawk(1)
  18.      manual page.

  19.      The /usr/bin/awk utility scans each input filename for lines
  20.      that  match  any of a set of patterns specified in prog. The
  21.      prog string must be enclosed in single quotes ( ')  to  pro-
  22.      tect  it  from the shell. For each pattern in prog there can
  23.      be an associated action performed when a line of a  filename
  24.      matches  the  pattern.  The set of pattern-action statements
  25.      can appear literally as prog or in a file specified with the
  26.      -f  progfile option. Input files are read in order; if there
  27.      are no files, the standard input is read. The file name  '-'
  28.      means the standard input.

  29. OPTIONS
  30.      The following options are supported:

  31.      -f progfile     awk uses the set of patterns it  reads  from
  32.                      progfile.

  33.      -Fc             Uses the character c as the field  separator
  34.                      (FS)  character.   See  the discussion of FS
  35.                      below.

  36. USAGE
  37.   Input Lines
  38.      Each input line is matched against the  pattern  portion  of
  39.      every  pattern-action  statement;  the  associated action is
  40.      performed for each matched pattern. Any filename of the form
  41.      var=value  is  treated as an assignment, not a filename, and
  42.      is executed at the time it would have been opened if it were
  43.      a filename. Variables assigned in this manner are not avail-
  44.      able inside a BEGIN rule, and are assigned after  previously
  45.      specified files have been read.

  46.      An input line is normally made up  of  fields  separated  by
  47.      white  spaces.  (This default can be changed by using the FS

  48. SunOS 5.10          Last change: 22 Jun 2005                    1
复制代码

论坛徽章:
0
2 [报告]
发表于 2011-03-26 10:58 |只看该作者
没人回答哦...我自己解决啦...
使用nawk替换awk就可以了.

论坛徽章:
10
处女座
日期:2015-01-22 16:08:50技术图书徽章
日期:2018-09-13 11:25:52技术图书徽章
日期:2018-09-13 11:25:45技术图书徽章
日期:2018-09-13 11:25:37技术图书徽章
日期:2018-09-13 11:25:29黑曼巴
日期:2018-06-04 09:03:192017金鸡报晓
日期:2017-01-10 15:19:56极客徽章
日期:2016-12-07 14:03:402015年迎新春徽章
日期:2015-03-04 09:50:28技术图书徽章
日期:2018-09-13 11:26:01
3 [报告]
发表于 2011-03-27 16:10 |只看该作者
厉害
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP