[SOLVED] bash script: parameter expansion in {1..$stuff} for example
by ArfaSmif from LinuxQuestions.org on (#5T60B)
I am using the following in a script
stuff=`dnf history|awk 'NR==3'|cut -d\| -f1|sed -r 's/\s+//g'`
which simply produces a parameter which looks like a number (eg. 580)
I want to use the value of "stuff" as a number in the rest of the script as in:-
for i in {1..$stuff}
do
something else
done
I can't work out how to make $stuff behave as a number and be used the way I
want it in the {1..$stuff} part of the script.
When I print out the value of "i" I get
i={1..580} (the 580 varies depending on the value of stuff.)
How to get this to work? Thanks.
stuff=`dnf history|awk 'NR==3'|cut -d\| -f1|sed -r 's/\s+//g'`
which simply produces a parameter which looks like a number (eg. 580)
I want to use the value of "stuff" as a number in the rest of the script as in:-
for i in {1..$stuff}
do
something else
done
I can't work out how to make $stuff behave as a number and be used the way I
want it in the {1..$stuff} part of the script.
When I print out the value of "i" I get
i={1..580} (the 580 varies depending on the value of stuff.)
How to get this to work? Thanks.