1.sed打印文本第一行和最后一行
[root@ecs-76840553 sed]# cat chongfu.txt test 30 Hello 95 Linux 85 test 30 Hello 95 Linux 85 test 30 Hello 95 Linux 85 [root@ecs-76840553 sed]# sed -n '1p' chongfu.txt #打印第一行 test 30 [root@ecs-76840553 sed]# sed -n '$p' chongfu.txt #打印第最后一行 Linux 85 [root@ecs-76840553 sed]#
2.删除第一行;添加11到第一行文本;修改3为333
[root@ecs-76840553 sed]# cat number.txt
1
2
3
[root@ecs-76840553 sed]# sed -i '1d' number.txt
[root@ecs-76840553 sed]# cat number.txt
2
3
[root@ecs-76840553 sed]# sed -i '1i11' number.txt
[root@ecs-76840553 sed]# cat number.txt
11
2
3
[root@ecs-76840553 sed]# sed -i '/3/c333' number.txt
[root@ecs-76840553 sed]# cat number.txt
11
2
333
[root@ecs-76840553 sed]#
标签:练习,number,sed,ecs,76840553,txt,root From: https://www.cnblogs.com/joyware/p/16664425.html