在Bash中模擬一個do-while循環的最佳方式是什麼?在Bash中模擬一個do-while循環
我可以在進入while
循環之前檢查條件,然後繼續重新檢查循環中的條件,但這是重複的代碼。有更清潔的方法嗎?我的腳本
僞代碼:
while [ current_time <= $cutoff ]; do
check_if_file_present
#do other stuff
done
如果$cutoff
時間後推出此不執行check_if_file_present
,和一個做,而會。
你在找'until'開關嗎? – 2013-05-10 19:52:41
@MichaelGardner'直到'也會在執行循環體之前評估條件 – Alex 2013-05-10 20:09:53
啊,我明白了,我誤解了你的困惑。 – 2013-05-10 20:34:10