simple parameter expansion
how would you guys go about adding a zero to the beginning if the integer in the parameter expansion is one digit, and ignoring it if the parameter expansion is 2 digits.
Code:
[casper@casper]$ for i in {6..11}; do echo "201309${i}.txt.bz2"; done i need to expand the range to : Code:
20130906.txt.bz2 |
Recent versions of bash accept zeroes in front of the first number:
Code:
$ echo {06..11} Code:
for i in {6..11} Code:
day=20130906 |
see: http://wiki.bash-hackers.org/commands/builtin/printf
for i in {6..11}; do printf "201309%02d.txt.bz2\n" $i; done |
amazing - thanks
|
All times are GMT -5. The time now is 08:38 AM. |