What is the significance of -n parameter passed to sed command?

后端 未结 2 1139
庸人自扰
庸人自扰 2021-01-24 18:38

Can someone please tell me how does sed -n \'1!p work ? Below is the full command which I am using to sort my pods in k8s based on nodes they are assigned.

2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-24 18:55

    From info sed:

    -n: By default, 'sed' prints out the pattern space at the end of each cycle through the script (*note How 'sed' works: Execution Cycle.). These options disable this automatic printing, and 'sed' only produces output when explicitly told to via the 'p' command.

    1p: print first line

    1!p: do not print first line.

提交回复
热议问题