sed总结

在使用sed把镜像源从国外改为清华源遇到的两个报错
sed -Ei.bak -e '/^baseurl/s/http(.*)com/https:\/\/mirrors.tuna.tsinghua.edu.cn\/ceph/' -e '/^gpgkey/s/https(.*)com/https:\/\/mirrors.tuna.tsinghua.edu.cn\/ceph/' /etc/yum.repos.d/ceph.repo

sed: -e expression #1, char 64: unknown option to `s'

原因是 替换的字符有 / 未用 \ 转义

sed: -e expression #1, char 68: unterminated `s' command

原因 /xx/s/mm/yy/ 最后一个 / 忘加

sed中 空格、<、>、. 不需要转义

posted @ 2021-06-10 17:52  windman  阅读(167)  评论(0编辑  收藏  举报