I am having trouble with the following command in Unix Bash Shell:
echo "This is some text" | cat dashes - dashes
"dashes" is a file containing the line of text: "---------------------------------"
From my understanding, the left command's stout stream becomes the right commands stdin stream. What I expected to be printed was:
This is some text
---------------------------------
But what actually printed was this:
---------------------------------
This is some text
---------------------------------
So I have two questions:
What is happening when the echo pipes into the cat, to make the given output?
How does the " - dashes" at end of the command work?
This is expected because -
in between 2 file names means print all the data from stdin . Take this example:
date | cat dashes - dashes
---------------------------------
Fri May 29 05:49:05 EDT 2015
---------------------------------
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.