Unix pipes - echo and cat

I am having trouble with the following command on the Unix Bash Shell:

echo "This is some text" | cat dashes - dashes

      

"dash" is a file containing a line of text: "---------------------------------"

From my understanding, the left stout stream command becomes the correct stdin stream commands. I expected to be printed:

This is some text
---------------------------------

      

But what was actually printed:

---------------------------------
This is some text
---------------------------------

      


I have two questions:

  • What happens when the echoes enter the cat to draw this conclusion?

  • How does the dash at the end of a command work?

+3


source to share


1 answer


This is expected because -

between two filenames means printing all data from stdin . Take this example:



date | cat dashes - dashes
---------------------------------
Fri May 29 05:49:05 EDT 2015
---------------------------------

      

+2


source







All Articles