The | command is called a pipe. It is used to pipe, or transfer, the standard
output from the command on its left into the standard input of the command on
its right.
A pipe is a form of redirection (transfer of standard output to some other
destination) that is used in Linux and other Unix-like operating systems to
send the output of one
Pipe is used to combine two or more commands, and in this, the output of one
command acts as input to another command, and this command’s output may act as
input to the next command and so on. It can also be visualized as a temporary
connection between two or more commands/ programs/ processes. The command line
programs that do the further processing are referred to as filters.
The syntax for the pipe or unnamed pipe command is the | character between any
two commands:
Command-1 | Command-2 | …| Command-N
Ex:
$ ls -l | more
Eplanation:
The more command takes the output of $ ls -l as its input. The net effect
of this command is that the output of ls -l is displayed one screen at a time.
The pipe acts as a container which takes the output of ls -l and gives it to
more as input
# count line using pipe operation (|)
$ echo "Welcome" | wc -l
1
# Count character
$ echo "Welcome" | wc -c
8
# Count line in the text file and list in sorted order
$ wc -l *.txt | sort -n
2 requirements.txt
83 log.txt
123 log_bkp.txt
208 total