today I started learning bash and I have an issue. I made a script which prompts the user to enter how many elements the want in an array and using a for loop it allows the user enter the elements till the capacity is met. How can I store the data in an array?.
my code:
#!/bin/bash
##Declaring an array to store no.Processes
declare -A execution
##Enter number of process
echo "Enter number of Processes: ";
read number_of_process
for ((index=0;index<$number_of_process;index++))
do
i=$(($index+1))
echo "Enter burst time of P$i:";
read execution
done
echo "Number of Processes = $i";
execution+=("$value")shtag on this question is unclear. In general, you should tag for only one shell at a time; and even when theshexecutable is provided by bash (which is not the case everywhere: many common operating systems like Ubuntu haveshprovided by other implementations such as dash), it turns off several features for better compatibility with the POSIX sh specification when called under that name.