我有一个urlwatch .yaml具有这种格式的文件:
name: 01_urlwatch update released
url: "https://github.com/thp/urlwatch/releases"
filter:
- xpath:
path: '(//div[contains(@class,"release-timeline-tags")]//h4)[1]/a'
- html2text: re
---
name: 02_urlwatch webpage
url: "https://thp.io/2008/urlwatch/"
filter:
- html2text: re
- grep: (?i)current\sversion #\s Matches a whitespace character
- strip # Strip leading and trailing whitespace
---
name: 04_RansomWhere? Objective-See
url: "https://objective-see.com/products/ransomwhere.html"
filter:
- html2text: re
- grep: (?i)current\sversion #\s Matches a whitespace character
- strip #Strip leading and trailing whitespace
---
name: 05_BlockBLock Objective-See
url: "https://objective-see.com/products/blockblock.html"
filter:
- html2text: re
- grep: (?i)current\sversion #(?i) \s
- strip #Strip leading and trailing whitespace
---
我需要根据name: . 在此示例中,第一次和第二次出现的name: 后面是正确的索引号,但第三次和第四次不是。
在上面的示例中,第三次和第四次出现的name: 索引号将重新索引到03_文本04_字符串之前。即:一个两位数的索引号和一个下划线。
此外,此字符串的某些实例#name: 不应计入重新索引。(它们已被注释掉,因此这些行不会被 执行urlwatch)
我尝试使用 sed 但无法根据字符串的出现生成索引号。我没有 GNU sed,但如果这是唯一的方法,我可以安装。