求助,在SunOS中的awk的使用问题.

发布于 2022-09-30 19:11:40 字数 5013 浏览 18 评论 0

我有一段如下代码在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

复制代码

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柏林苍穹下 2022-10-07 19:11:40

没人回答哦...我自己解决啦...
使用nawk替换awk就可以了.

撩动你心 2022-10-07 19:11:40

厉害

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文