What actually the meaning of “-n” in sed?

后端 未结 4 1663
粉色の甜心
粉色の甜心 2021-01-01 23:05

According to http://linux.about.com/od/commands/l/blcmdl1_sed.htm

suppress automatic printing of pattern space

I\'ve tested wi

4条回答
  •  渐次进展
    2021-01-01 23:49

    $ echo "a b c d" | sed "s/a/apple/"
    apple b c d

    The pattern space is printed implicitly.

    $ echo "a b c d" | sed -n "s/a/apple/"

    No output.

    $ echo "a b c d" | sed -n "s/a/apple/p"
    apple b c d

    Explicitly print the pattern space.

提交回复
热议问题