couting with fixed digits inside bashscripts through string manipulation
#!/bin/bash COUNT=0 while [ $COUNT -le 10000 ] do echo 000$COUNT |\ rev |\ cut -c 1-4 |\ rev COUNT=`expr $COUNT + 1` done exit 0;
print a number of zeros + the countervariable (948 -> 00948)
revert this string (00948 -> 84900)
select first e.g. four digits (84900 -> 8490)
revert the string (8490 -> 0948)
This was before i learned about
zero padding
filenames.
But as we all know,
there is more than way to do it ;)