bash equivalent to C increment operator
I am modifying my init scripts to run a bootsplash progress bar. A seperate script is called to advance the bar, and it works like this
Code:
/etc/bootsplash/progress.sh <position> <num actions> ... Code:
NUM_ACTIONS=... |
From Advanced Bash Scripting Guide:
y=`expr $y + 1` Increment a variable, with the same effect as let y=y+1 and y=$(($y+1)) . |
I wonder if this would be of any use to you......
_________________________________________ #!/bin/bash # echo "" echo -n "Num_Actions: " read NUM for ((POS=1; POS <=$NUM ; POS++)); do echo done # /etc/bootsplash/progress.sh $POS $NUM_ACTIONS # #End |
y=$[$y+1]
: you can even leave the $ off the y. y=$[y+1] : but to me it looks confusing. a little faster, of course so is c, c++, perl, and python. probably even java. I like bash too. :) Yea! only 5 years late too! Maybe someone will find this useful. |
Code:
bash-3.1$ x=5 |
you could also use "((" and "))"
$: x=1 $: ((x++)) $: echo $x 2 |
All times are GMT -5. The time now is 09:47 AM. |