Take 10 user inputs and output to file?

I want a script that will prompt a user to enter 10 numbers and out put them into a file. This what I have so far, but isn't working. I'm guessing it's something easy I'm not seeing. Thanks for any help.

#!/usr/bin/ksh

echo "Enter 10 numbers"
for i in 1 2 3 4 5 6 7 8 9 10
do
  read ....  >> numbers
done
#!/usr/bin/ksh

echo "Enter 10 numbers"
for i in 1 2 3 4 5 6 7 8 9 10
do
  read a
  echo $a
done > numbers
1 Like

Awesome. Thanks!

The highlighted line above may be shortened as for i in {1..10} .

1 Like

Oh yeah. Forgot about that too. Thanks.

Is it possible to change the code based on the number of user inputs . For example user will give n number of inputs which needs to be store on a file and perform task based on the values of the file .

I'd use a different sort of loop for that.

N=10

while [ "$N" -gt 0 ]
do
        N=`expr $N - 1`
        ...
done

Is it possible to change the code based on the number of user inputs . For example user will give n number of inputs which needs to be store on a file and perform task based on the values of the file .

Yes, it is.

How, depends on what you need it to do.