I am uncertain on how to correctly all a variable in a for loop. I have currently set a variable equal to the total number of lines in a file and want to use it in a for loop that will run a set of code.
I tried the following:
variable=$(awk 'END { print NR }' file)
I want to use this variable in a for loop, here is a simple example:
for i in {1..$variable}; do
print ${i}
done
This doesn't work as I think I have called the variable
incorrectly.
Any help would be greatly appreciated. Thank you.