If you want the user user to enter lines and add them to your file until the user enters ^ D, you can use the following script:
echo "Please give input" while read -r line; do echo "Enter next line or ^D" echo "${line}" > template.txt done echo "After loop"
You do not need to check for the presence of ^ D, which will be recognized by reading without doing anything extra. Therefore, you do not need to use CTRL-V CTRL-D in vi .
Walter A Nov 01 '15 at 10:31 on 2015-11-01 10:31
source share