Take this way, let’s use the Kill command as the first example:
Let’s say the output of the "cat /tmp/server.pid" command is something like "3193". As you did the first time, your command with pipe + Kill would look something like: "3193 Kill -9"; but we know that this will not work because we have to execute the command "Kill -9" followed by a parameter, in case the pid of the process we want to close; so the correct thing would be to turn this parameter into a variable, which is not possible with the use of the pipe, because it serves to "concatenate" and/or redirect commands.
How you use the pipe depends solely on how you organize your commands, see:
"As a beginner in Linux I realized the relevance of pipe to make shell commands more practical and easier to write and therefore decided to share my experience on this command.
Pipe is one of the ways that Linux can use for inter-process communication. In a simple way we could say that the pipe is nothing more than the chain of processes. At first glance the pipe may not even attract attention from beginners, but it is a very powerful tool. This process chaining can be activated by the user via the "|" command. Now let’s demonstrate in the example below the potentiality of this tool:
$ ls | grep b | Sort -r | tee file.out | wc -l
- The "ls" command, as we well know, lists the contents of the directory,
but due to the pipe it does not send the result to the screen
command "grep b".
- The "grep b" command in turn filters the names of
files containing the letter "b". Due to the second pipe the output of
"grep b" command is sent to "Sort -r", which sorts the names in
rising order.
- The output of "Sort -r " is then passed to the command
"tee", which divides the data in two, as if it were a connection in t,
causing the information processed by the "Sort -r" command
are written in the "archive.out".
- Then the command "toilet -l"
counts the lines of the file "file.out". So we get as
result the amount of files containing the letter "b" printed on
screen and the name of those files in ".out file".
(...)
Reference: Using the pipe