linux pipe character |

    "|" is the pipe command operator, referred to as the pipe character.
    Use the pipe character "|" provided by Linux to separate the two commands, and the output of the command on the left side of the pipe character will be used as the input of the command on the right side of the pipe character . Using pipes continuously means that the output of the first command is used as the input of the second command, which in turn is used as the input of the third command, and so on.
    It should be noted that it can only process the correct output information transmitted by the previous instruction, that is, the information of standard output, and has no direct processing ability for standard error information.

 

Example:

-- Take out the line where root appears in the file /etc/passwd.

cat /etc/passwd | grep root

Use the cat command to get all the contents of /etc/passwd, and then pipe it to the grep command for filtering, filtering out the lines containing root.

 

Functionally equivalent to the following statement
grep root /etc/passwd

 

 

-- -- Take out the lines in /etc/passwd without root and nologin
cat /etc/passwd | grep -v root |grep -v nologin

 

Functionally equivalent to
grep -v root /etc/passwd | grep -v nologin

 

 

 -- Query the process that contains "bash" in the process description, and return the last process information.
ps -ef|grep bash| tail -1

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326976722&siteId=291194637