shell - 提取两个字符串之间的文本,但仅使用 sed 第一次出现?
问题描述
所以我有一个看起来像这样的字符串:
<tag>Hello world </tag> blah blah blah <tag> Good night !! </tag>
我只需要提取hello world。知道如何构建 sed 命令吗?
解决方案
使用简单的切割:
echo "<tag>Hello world </tag> blah blah blah <tag> Good night ls -ltrh cptrade* </tag>" | cut -d'>' -f2 | cut -d'<' -f1
推荐阅读
- perl - 如何检查 cidr 值是否有效
- c# - Encoding.GetString() 仅返回字节数组中的第一个字节
- javascript - 如何检测字符串中间的两个空格?
- bash - 在 Bash 中,我应该使用声明而不是本地和导出吗?
- typescript - Typescript:如何从包含泛型的类型中获取所有可能的返回值
- android - 如何在同一查询响应中返回的字段上过滤 GraphQL 嵌套数组?或者如何在多个字段上创建 GraphQL 关系?
- docker - 通过 kubectl 暴露服务时,从节点主机上没有监听端口
- javascript - 在循环 ForEach 之前等待确认
- html - 导航项下方带有子菜单的全宽下拉菜单
- selenium - 范围报告仅保存 Jenkins 中最后一项作业的最后一项结果