Extract part of a string using Sed

大兔子大兔子 提交于 2019-12-13 05:20:07

问题


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".

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

Your help is much appreciated Thanks, Jin


回答1:


Just remove /services and whatever follows:

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


来源:https://stackoverflow.com/questions/33865738/extract-part-of-a-string-using-sed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!