使用Sed提取字符串的一部分

使用Sed提取字符串的一部分

问题描述:

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

I want to extract first part of a string using "Sed" utility. grep and awk are not available in the environment. The input is

" https://jintestexample.example.com/services/get/latest/accounts ".

我需要提取"/services"之前的字符串.我只需要使用sed.

I need to extract the string before "/services". I have to use sed only.

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

Your help is much appreciated Thanks, Jin

只需删除/services以及以下内容:

Just remove /services and whatever follows:

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