问题
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