我从命令替换变量得到以下输出:
'Enable succeeded: [stdout]Proc is not up yet, retrying...Proc is not up yet, retrying...Proc is not up yet, retrying...Proc is not up yet, retrying...Proc is not up yet, retrying...Proc is not up yet, retrying...[stderr]'
字符串Proc 尚未启动,正在重试...可能会出现未知次数,因为我只需要捕获一次出现,我为此使用了grep -o -m1,它确实有效。问题是我还需要允许我的变量捕获多个不同的特定字符串(例如Proc 已启动并正在运行!),这同样可能出现未知次数。
请注意,字符串的每次出现都由换行符分隔,理想情况下,我还想删除最后一个 \n,当我使用 grep -m1 时,它保留在字符串的最后。
如果你想 grep 多个表达式,\|
像这样分隔它们:
grep "Proc is not up yet, retrying...\|Proc is up and running!"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句