Skip to main content
#!/bin/bash
i=1
while read x
do
   i=$((i+1$i + 1))
   echo $i
done < <(find .tmp -type f)
echo $i

https://stackoverflow.com/questions/7390497/bash-propagate-value-of-variable-to-outside-of-the-loop

#!/bin/bash
i=1
while read x
do
   i=$((i+1))
   echo $i
done < <(find . -type f)
echo $i

https://stackoverflow.com/questions/7390497/bash-propagate-value-of-variable-to-outside-of-the-loop

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

https://stackoverflow.com/questions/7390497/bash-propagate-value-of-variable-to-outside-of-the-loop

Source Link
Kamaraj
  • 4.4k
  • 1
  • 15
  • 19

#!/bin/bash
i=1
while read x
do
   i=$((i+1))
   echo $i
done < <(find . -type f)
echo $i

https://stackoverflow.com/questions/7390497/bash-propagate-value-of-variable-to-outside-of-the-loop