红联Linux门户
Linux帮助

关于sed命令参数-e的疑问

发布时间:2011-11-15 11:12:17来源:红联作者:irwin520
我想请教的是命令 sed -n -e '/music/'p -e '/music/'= quote.txt 中-e 起什么作用,为什么结果是下面标记红色部分?
[irwin@IRWIN test]$ sed -n -e '/music/'p -e '/music/'= quote.txt
It was an evening of splendid music and company.
2


操作文件quote.txt内容如下:
[irwin@IRWIN test]$ cat quote.txt
The honeysuckle band played all night long for only $90.
It was an evening of splendid music and company.
Too bad the disco floor fell through at 23:10.
The local nurse Miss P.Neave was in attendance.
文章评论

共有 9 条评论

  1. shell_master 于 2011-11-26 13:34:02发表:

    用男人......如果你能看得懂英文.....{:2_93:}

  2. dhqrx 于 2011-11-16 13:41:05发表:

    :0wszxc

  3. irwin520 于 2011-11-16 11:14:20发表:

    7# age


    :0)1 o(∩∩)o...哈哈 现在明白了,多谢。

  4. age 于 2011-11-16 10:14:52发表:

    引用:
    2# liyf86886
    我照方法做了测试,发现源文件没有改变。如下结果。

    $ sed -n -e 's/music/*****/g' quote.txt
    $ cat quote.txt
    The honeysuckle band played all night long for only $90.
    It was an evenin ...
    irwin520 发表于 2011-11-16 09:25

    sorry,记错了,写回文件是 -i
    -e是允许多重编辑{:3_117:}

  5. irwin520 于 2011-11-16 09:28:17发表:

    4# wonderall


    基本上明白了。我再学习学习下。多谢。

  6. irwin520 于 2011-11-16 09:25:24发表:

    2# liyf86886
    我照方法做了测试,发现源文件没有改变。如下结果。

    [irwin@IRWIN test]$ sed -n -e 's/music/*****/g' quote.txt
    [irwin@IRWIN test]$ cat quote.txt
    The honeysuckle band played all night long for only $90.
    It was an evening of splendid music and company.
    Too bad the disco floor fell through at 23:10.
    The local nurse Miss P.Neave was in attendance.

  7. wonderall 于 2011-11-15 18:50:38发表:

    要对一个文件重复操作就要用-e,第一次操作打印出包含music的行,第二次操作继续打印包含music行,所以那行要打印两次

  8. age 于 2011-11-15 14:14:20发表:

    -e 表示显示同时修改原文件
    不加-e只是读取数据,然后输出

  9. liyf86886 于 2011-11-15 12:50:45发表:

    路过{:3_114:}