bash change variable in while loop 1

bash change variable in while loop

i=1
while read x; do
   i=$(($i + 1))
   echo $i
done <<<$(find tmp -type f)
echo $i

Here is what the above code is Doing:
1. The first line is a comment.
2. The second line is a shebang.
3. The third line is a variable assignment.
4. The fourth line is a while loop.
5. The fifth line is a read statement.
6. The sixth line is an arithmetic expression.
7. The seventh line is an echo statement.
8. The eighth line is a here document.
9. The ninth line is an echo statement.

Similar Posts