【问题标题】:Extract part of a string using Sed使用 Sed 提取字符串的一部分
【发布时间】:2015-11-23 15:56:24
【问题描述】:

我想使用“Sed”实用程序提取字符串的第一部分。 grep 和 awk 在环境中不可用。输入是

https://jintestexample.example.com/services/get/latest/accounts”。

我需要提取“/services”之前的字符串。我只能使用 sed。

非常感谢您的帮助 谢谢, 金

【问题讨论】:

    标签: sed extract


    【解决方案1】:

    只需删除 /services 和以下任何内容:

    echo "https://jintestexample.example.com/services/get/latest/accounts" \
    | sed -e 's%/services.*%%'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-08
      • 2014-05-31
      • 2016-06-17
      • 2020-12-18
      • 1970-01-01
      相关资源
      最近更新 更多