STDIN#

read STDIN from a file#

cat < file.txt

read STDIN from heredoc#

See Heredocs

read STDIN from a line or variable#

cat <<< "hello"

This is especially useful to put a variable’s value into the STDIN of a program, e.g.

x="foo bar baz"
cat <<< "$x"

Simple splitting of a variable into its parts:

x=foo.bar
IFS=$'.' read module name <<< $x

test $module == foo
test $name == bar