免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1537 | 回复: 5
打印 上一主题 下一主题

请教命令 sed 的用法 man 又看不懂 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-03-07 16:37 |只看该作者 |倒序浏览
如何使用 sed 删除文件中含有某个指定字串的那行。

论坛徽章:
0
2 [报告]
发表于 2003-03-07 17:10 |只看该作者

请教命令 sed 的用法 man 又看不懂

sed 's/pattern/d' filename

vi中
:g/pattern/d

前两天刚友人留过,应该先查一下,

论坛徽章:
0
3 [报告]
发表于 2003-03-07 20:02 |只看该作者

请教命令 sed 的用法 man 又看不懂

sed '/pattern/d' file >file1

论坛徽章:
0
4 [报告]
发表于 2018-03-26 17:51 |只看该作者
本帖最后由 华北帝鹰 于 2018-03-26 17:56 编辑

回复个帖子,总不是立即生效,真坑爹!

论坛徽章:
0
5 [报告]
发表于 2018-03-26 17:53 |只看该作者
sed -i '/123/d' file1;
123:所谓的某个指定字串
file1:所谓的某个文件

论坛徽章:
0
6 [报告]
发表于 2018-03-27 11:11 |只看该作者
2 3 楼。对。1楼,说人前自己先嫩嫩

[root@localhost shell]# cat 105.txt
b001        020
c030         030
c030           300
[root@localhost shell]# sed  's/b001/d' 105.txt               
sed: -e expression #1, char 8: unterminated `s' command
[root@localhost shell]# sed  '/b001/d' 105.txt  
c030         030
c030           300
[root@localhost shell]# cat 105.txt
b001        020
c030         030
c030           300
[root@localhost shell]# sed  -i '/b001/d' 105.txt
[root@localhost shell]# cat 105.txt
c030         030
c030           300
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP