循环 bash 脚本调用的最简单方法
我有一个 bash 脚本。我希望这个脚本每次调用它时都能做不同的事情(模数三)。像这样:
First script call => echo "call 1"
Second script call => echo "call 2"
Third script call => echo "call 3"
Fourth script call => echo "call 1"
Fifth script call => echo "call 2"
Sixth script call => echo "call 3"
Seventh script call => echo "call 1"
...
最简单的方法是什么?
请注意,脚本并不重要。例如:重启后计数器可以回到一:
...
n script call => echo "call 1"
n+1 script call => echo "call 2"
* reboot *
n+2 script call => echo "call 1"
...
就可以了。
感谢您的见解。
I have a bash script. I would like this script to do something different every time I call it (modulus three). Something like this :
First script call => echo "call 1"
Second script call => echo "call 2"
Third script call => echo "call 3"
Fourth script call => echo "call 1"
Fifth script call => echo "call 2"
Sixth script call => echo "call 3"
Seventh script call => echo "call 1"
...
What would be the simplest way to do this ?
Note that the script is not critical. For example : the counter can go back to one after a reboot :
...
n script call => echo "call 1"
n+1 script call => echo "call 2"
* reboot *
n+2 script call => echo "call 1"
...
is OK.
Thank you for your insights.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最简单的方法可能是将值存储在文件中
Easiest approach is probably to just store the value in a file
在重击中:
In Bash: