Reputation: 14866
If a command returns a list of strings I can pipe it to another command.
For instance:
command1 | command2
Lets say command1
returns 2 lines. Is there a way to do the same thing on the command line without a command that generates the lines?
I know this below doesn't work but maybe explains better what I mean:
("string 1", "string 2) | command2
I want to manually specify 2 lines to send into the pipe instead of using a command to generate them.
Is that possible?
Upvotes: 2
Views: 730
Reputation: 780974
You can use echo
commands:
{ echo "string 1"; echo "string 2"; } | command2
or printf
to do it with one command:
printf 'string 1\nstring 2\n' | command2
But if it's many lines, a here-doc is usually easier:
command2 <<EOF
string 1
string 2
EOF
Upvotes: 2