Increment variable value by 1 ( shell programming)

前端 未结 5 2026
太阳男子
太阳男子 2020-12-24 11:28

I am a beginner to shell programming and it sounds like a very stupid question but i cant seem to be able to increase the variable value by 1. I have looked at tutorial but

5条回答
  •  旧时难觅i
    2020-12-24 11:46

    The way to use expr:

    i=0
    i=`expr $i + 1`
    

    the way to use i++

    ((i++)); echo $i;
    

    Tested in gnu bash

提交回复
热议问题