#!/bin/bash for i in 1 2 3 4 5 do echo $i done ~ #!/bin/bash cd /tmp ls *.sh > ls.log y=1 for i in $(cat ls.log) do echo $y y=$(($y + 1)) done ~ ~