Generate a 0 padded sequence with a string prefix
by iicapn from LinuxQuestions.org on (#5MTX8)
I'm trying to generate a list of values like this:
Hi000
Hi001
Hi002
..
Hi999
My bash code currently looks like this:
Code:prefix=Hi
number=1000
for i in {1..$number}; do
# n=$(seq -f "%03g" 0 $number_keys)
n=$(seq -w 0 $number)
echo $prefix$n
((n=n+1))
done(the commented out line is something I tried but failed at)
The result (using number=10) is:
Code:./test.sh: line 10: ((: 00
01
02
03
04
05
06
07
08
09
10: syntax error in expression (error token is "01
02
03
04
05
06
07
08
09
10")I've tried a lot of things but can't quite put my finger on it... Thank you all in advance. :-)
Hi000
Hi001
Hi002
..
Hi999
My bash code currently looks like this:
Code:prefix=Hi
number=1000
for i in {1..$number}; do
# n=$(seq -f "%03g" 0 $number_keys)
n=$(seq -w 0 $number)
echo $prefix$n
((n=n+1))
done(the commented out line is something I tried but failed at)
The result (using number=10) is:
Code:./test.sh: line 10: ((: 00
01
02
03
04
05
06
07
08
09
10: syntax error in expression (error token is "01
02
03
04
05
06
07
08
09
10")I've tried a lot of things but can't quite put my finger on it... Thank you all in advance. :-)