|
) in BashThe pipe (|
) in Bash is used to direct the output of one command (stdout) as the input (stdin) to another command. This allows you to combine multiple commands in powerful ways to process data efficiently.
command1 | command2
command1
: The first command generates output.command2
: The second command takes the output of command1
as its input.Use ls
to list files and wc -l
to count the lines of output:
ls -lhs | wc -l
Explanation:
ls -lhs
: Lists files and directories in human-readable sizes.