In this post, we will see how to resolve bash pipe will convert ‘\t’ to ‘\n’?
Question:A little bit confused on pipe behaviors
lswithout any options specified, it will print result and split it with ‘\t’ ?
Best Answer:From the POSIX specification for
The default format shall be to list one entry per line to standard output; the exceptions are to terminals or when one of the -C, -m, or -x options is specified. If the output is to a terminal, the format is implementation-defined.
What you see when you pipe the output to another command is the default output: each file starts on a new line.
There is no standard for what
lsproduces when the output is a terminal, but commonly implementations behave as if the
-Coption were provided:
-C Write multi-text-column output with entries sorted down the columns, according to the collating sequence. The number of text columns and the column separator characters are unspecified, but should be adapted to the nature of the output device. This option disables long format output.
If you have better answer, please add a comment about this, thank you!