Oh, I'm sorry to give a wrong script. It has been modified below: #!/bin/bash SUM=0 while read NUMBER do SUM=$(expr $SUM + $NUMBER) # Yes, this line. done echo $SUM