gpt4 book ai didi

shell - 在 sed 中,我可以防止\S 匹配括号吗?

转载 作者:行者123 更新时间:2023-12-03 23:34:00 24 4
gpt4 key购买 nike

输入文件有这个内容

you have to identify (http://third-view.herokuapp.com/) 

我想删除 URL,所需的输出是

you have to identify ()

但下面的 Sed 命令也删除了 ')' 括号。

sed -i -e 's!http[s]\?://\S*!!g' file

最佳答案

() 添加到要终止的字符列表中,方法是将它们添加到显式字符类中:

sed -r -i -e 's!http[s]?://[^[:space:]()]*!!g' file

关于shell - 在 sed 中,我可以防止\S 匹配括号吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63744855/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com