Reputation: 24150
I know that we can use a file as stdin like
program << file.txt
but is it possible to use a string as stdin ?
Upvotes: 1
Views: 2277
Reputation: 26086
bash
supports "here strings" with the following syntax:
program <<<"your input goes here"
This will be treated approximately the same as
echo "your input goes here" > tmp
program < tmp
Upvotes: 3
Reputation: 81694
You can use syntax called a here document:
program << EOF
input
more input
even more input
EOF
This is supported in several UNIX shells, as well as in some scripting languages like Perl.
Upvotes: 3