Send string to stdin
问题 Is there a way to effectively do this in bash: /my/bash/script < echo \'This string will be sent to stdin.\' I\'m aware that I could pipe the output from the echo such as this: echo \'This string will be piped to stdin.\' | /my/bash/script 回答1: You can use one-line heredoc cat <<< "This is coming from the stdin" the above is the same as cat <<EOF This is coming from the stdin EOF or you can redirect output from a command, like diff <(ls /bin) <(ls /usr/bin) or you can read as while read line