Skip to main content
added 183 characters in body
Source Link
cYrus
  • 21.9k
  • 9
  • 75
  • 80

ls | echo prints just a blank line because echo reads no input; the last command of the pipeline is actually echo that prints nothing but a blank line.

Generally:

a | b

makes sure that the output of a become the input of b. I suggest you to read the PipelinePipelines section of man bash.


If you really want to use ls and echo together here's some (pretty useless) examples:

ls | xargs -L 1 echo
echo `ls`
for i in `ls` ; do echo $i ; done

ls | echo prints just a blank line because echo reads no input; the last command of the pipeline is actually echo that prints nothing but a blank line.

Generally:

a | b

makes sure that the output of a become the input of b. I suggest you to read the Pipeline section of man bash.

ls | echo prints just a blank line because echo reads no input; the last command of the pipeline is actually echo that prints nothing but a blank line.

Generally:

a | b

makes sure that the output of a become the input of b. I suggest you to read the Pipelines section of man bash.


If you really want to use ls and echo together here's some (pretty useless) examples:

ls | xargs -L 1 echo
echo `ls`
for i in `ls` ; do echo $i ; done
Source Link
cYrus
  • 21.9k
  • 9
  • 75
  • 80

ls | echo prints just a blank line because echo reads no input; the last command of the pipeline is actually echo that prints nothing but a blank line.

Generally:

a | b

makes sure that the output of a become the input of b. I suggest you to read the Pipeline section of man bash.