I have the following bash script, saved as script.sh:
echo "Do that? [Y,n]"
read input
if [[ $input == "Y" || $input == "y" ]]; then
echo "do that"
else
echo "don't do that"
fi
On the terminal, I would like to run the script together with input in a single line. I attempted
./trial.sh < y
However, I receive the following output
bash: y: No such file or directory
How can I resolve this?
<foo, you are redirecting from a file namedfoo. In your case, a file namedywould be needed. The file does not exist, and hence the error message.