shell Linux匹配开始和结束以及替换

u0sqgete  于 2023-01-26  发布在  Shell
关注(0)|答案(1)|浏览(140)

我有一个文件,其中只包含一行,但它真的真的很长。我想从该行的特定部分,并取代其他东西。
以下是示例测试:

This is an exemple text should be very long long text in my real case i am trying to find something like start/end with to replace to something else.

我想象-〉以**"示例文本"开头"实际案例"结尾**
预期结果:* "示例文本在我的实际情况中应该是很长的文本"*
替换:空的
你能帮帮我吗?

sulc1iza

sulc1iza1#

查找this,假设您使用bash:

myString="This is an exemple text should be very long long text in my real case i am trying to find something like start/end with to replace to something else."
echo "${myString/"This is an exemple text should be very long long text in my real case i am trying to find something like start/end with to replace to something else."/"exemple text should be very long long text in my real case"}"

相关问题