I need to write a script that will add a line to a text file if Enter is pressed.
But, if Ctrl+D is pressed, I need to exit that loop in the bash.
touch texttest.txt
LINE="0"
while true; do
read LINE;
if [ "$LINE" == "^D" ]; then
break
else
echo "$LINE" >> texttest.txt
fi
done
Currently have something like this but cannot figure out how I am do exit the while loop when Ctrl+D is pressed instead of Enter.