Skip to main content

I'm new to bash and can't find a good tutorial to answer my question.

array=( item1 item2 item3 )
for name in ${array[@]}; do
    echo current/total
    ... some other codes
done

I want to calculate the "current"current and "total"total value, as the expected output of this being:

1/3
2/3
3/3

Thanks for any kind of tips.

I'm new to bash and can't find a good tutorial to answer my question.

array=( item1 item2 item3)
for name in ${array[@]}; do
    echo current/total
    ... some other codes
done

I want to calculate the "current" and "total" value, as the expected output of this being:

1/3
2/3
3/3

Thanks for any kind of tips

I'm new to bash and can't find a good tutorial to answer my question.

array=( item1 item2 item3 )
for name in ${array[@]}; do
    echo current/total
    ... some other codes
done

I want to calculate the current and total value, as the expected output of this being:

1/3
2/3
3/3

Thanks for any kind of tips.

edited tags
Link
Gilles 'SO- stop being evil'
  • 865.3k
  • 205
  • 1.8k
  • 2.3k
Source Link
AGamePlayer
  • 7.9k
  • 17
  • 49
  • 55

how to count the length of an array defined in bash?

I'm new to bash and can't find a good tutorial to answer my question.

array=( item1 item2 item3)
for name in ${array[@]}; do
    echo current/total
    ... some other codes
done

I want to calculate the "current" and "total" value, as the expected output of this being:

1/3
2/3
3/3

Thanks for any kind of tips