我有一个脚本,我想每 x 秒运行一次,直到输出发生变化。通过一个简单的 while 或 until 循环,我知道如何使用 grep 检查特定字符串的输出,但我想要做的是继续迭代循环,直到当前迭代的输出不等于前一次迭代的输出。
我怎样才能在 bash 中实现这一点?
我得到的最接近的是下面,命令在每次迭代中运行两次,但这会产生额外的运行,因为 while 循环无法记住上一次迭代的输出。
while [ "$(command)" = "$(command)" ]; do sleep 10m; done
Run Code Online (Sandbox Code Playgroud) bash ×1