相关疑难解决方法(0)

在Bash中模拟do-while循环

在Bash中模拟do-while循环的最佳方法是什么?

我可以在进入while循环之前检查条件,然后继续重新检查循环中的条件,但这是重复的代码.有更干净的方式吗?

我的脚本的伪代码:

while [ current_time <= $cutoff ]; do
    check_if_file_present
    #do other stuff
done
Run Code Online (Sandbox Code Playgroud)

check_if_file_present如果在$cutoff时间之后启动,这将不会执行,并且会执行.

bash loops do-while

123
推荐指数
5
解决办法
14万
查看次数

标签 统计

bash ×1

do-while ×1

loops ×1