【发布时间】:2015-11-23 15:56:24
【问题描述】:
我想使用“Sed”实用程序提取字符串的第一部分。 grep 和 awk 在环境中不可用。输入是
“https://jintestexample.example.com/services/get/latest/accounts”。
我需要提取“/services”之前的字符串。我只能使用 sed。
非常感谢您的帮助 谢谢, 金
【问题讨论】:
我想使用“Sed”实用程序提取字符串的第一部分。 grep 和 awk 在环境中不可用。输入是
“https://jintestexample.example.com/services/get/latest/accounts”。
我需要提取“/services”之前的字符串。我只能使用 sed。
非常感谢您的帮助 谢谢, 金
【问题讨论】:
只需删除 /services 和以下任何内容:
echo "https://jintestexample.example.com/services/get/latest/accounts" \
| sed -e 's%/services.*%%'
【讨论】: