You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

if-then语句仅作用于匹配字符串首个实例的问题咨询

if-then语句仅作用于匹配字符串首个实例的问题咨询

各位好,我目前碰到个小麻烦,有些相关知识不太清楚,也没法精准地描述问题(先跟大家说声抱歉)。我写的命令在处理$WARN这个变量时,只会返回第一个匹配到的实例,没办法把所有符合条件的条目都找出来。

先给大家展示下$WARN里的内容,我执行echo "$WARN"后得到的输出是:

(W) 2024-08-30T08:08:52 - Restart is required to toggle support
(W) 2024-08-30T09:59:30 - Failed to download RSS feed at 'https://aaa'. Reason: The connection to the remote server timed out
(W) 2024-08-30T10:00:30 - Failed to download RSS feed at 'https://bbb'. Reason: The connection to the remote server timed out
(W) 2024-08-30T10:00:30 - Failed to download RSS feed at 'https://ccc'. Reason: The connection to the remote server timed out
(W) 2024-09-13T08:59:44 - Failed to download RSS feed at 'http://xxx'. Reason: The remote server refused the connection
(W) 2024-09-13T08:59:44 - Failed to download RSS feed at 'http://yyy'. Reason: The remote server refused the connection
(W) 2024-09-13T08:59:44 - Failed to download RSS feed at 'http://zzz'. Reason: The remot...

我本来想把所有和RSS下载失败相关的条目都筛选出来,但现在的命令只抓到第一条匹配的结果就停止了,有没有大佬能指点下问题出在哪,或者该怎么调整命令才能匹配到所有符合条件的内容呢?

备注:内容来源于stack exchange,提问作者John

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 15:28:00