sed processes one line at a time without changing the contents of the file
sed defaults to printing after each line of data that has been processed
Read which line will first do regular matching. If it matches, let the SED command handle it, or it will be output directly to the screen
sed Using Method--Command Line Formatsed [-e,-n] 'Line location (regular)+sed command(operation)' file(s)
sed Using Method--Command Line Format parameter-e-e calls two sed command
sed Using Method--Command Line Format-nIndicates that the default print operation for sed is inhibit
If there is no -n added on,
If adding parameter of-n:
$sed -n '/root/p' passwd
root:x:0:0:root:/root:/bin/bash
It will output only one line, some people think that the sed command output is output two times, actually it is not two times output, it is the sed command itself will output all read lines. And the P command will print out the matching line, and -n can inhibit the printing behavior of sed by default.
sed Using Method--Command Line Format sed command pPrint out all the matching lines