Pipeline Pitfalls
Know about the scenarios when we should not use a pipeline.
We'll cover the following...
Cons of pipelines
The pipeline is a convenient Bash feature. We will apply it often when we work with the shell. Unfortunately, we can easily make a mistake while using the pipeline. Let’s consider its pitfalls through examples.
We can expect the same result from the following two commands:
find /usr/share/doc/bash-doc -name "*.html"
ls /usr/share/doc/bash-doc | grep "\.html"
These commands provide different results in some cases. The problem occurs when we pass the file names through the pipeline.
The root cause of the problem comes from the POSIX standard. The standard allows all printable characters in the file and directory names. This means that spaces and line breaks are allowed. The only forbidden character is the null character (NULL). This rule can lead to unexpected consequences.
Here is an example. We create a file in the home directory. The file name should contain the line break. This is a control ...