I'm trying to write a short shell script that lets me input a bunch of numbers, each followed by ENTER, and then use CTRL+D to stop taking input and to print the sum of the inputted numbers.
The result I'm looking for is something like this:
You can use
read -r VARNAME for that, e.g.:
#!/bin/bash sum=0 while read -r n; do ((sum += n)) done echo "$sum"