Copyright © 2008-2018, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2016mar6 Language: bash Q. How can I increment a variable in a loop? A. The modern way to increment a variable in bash is:((var++))where var is the name of your variable. In a loop:i=1 for orig in `ls *.jpg`; do padded=`printf '%03d' $i` mv $orig $padded.jpg ((i++)) done
Add a commentSign in to add a comment