【转】sed 的参数
1
2
3
4
5
a
b
c
d
e
a
1
2
3
4
5
b
c
d
e
[root@watchout2 ~]# touch /file
[root@watchout2 ~]# echo "aaaaaaaaaaaaaaaaaaaaaaaaaa" > /file
[root@watchout2 ~]# sed '/a/r /file' newfile (读入的文件在不同的路径)
a
aaaaaaaaaaaaaaaaaaaaaaaaaa
b
c
d
e
[root@watchout2 ~]#
a
b
c
d
e
[root@watchout2 ~]# cat bo ([root@watchout2 ~]# sed -n '/a/w bobo' newfile )
a
a
b
c
d
e
bobo
a
b
c
d
e
b
a
c
c
c
d
e
A
B
C
d
e
a
b
c
a
b
c
d
a
e
a
b
c
d
e
a
a
a
c
d
e
[root@watchout2 ~]# sed -e '/a/h' -e '$g' newfile
a
b
c
d
a
a
b
c
a
e
1
2
3
4
5
6
6
7
8
root:/tmp>sed -n '/6/p' num -n选项取消sed的默认行为(-p ),所以只打印“6”
6
root:/tmp>
1
2
3
4
5
7
8
root:/tmp>
1
2
3
4
5
root:/tmp>
1
2
3
4
5
6
7
root:/tmp>
1
2
3
4
5
7
8
root:/tmp>
8
2
3
4
5
6
7
8
root:/tmp>
8
2
3
4
5
6
7
8
root:/tmp>
1.6789
2.6789
3.6789
4.6789
5.6789
6.6789
7.6789
8.6789
root:/tmp>
1
2
3
4
5.6789
6
7
8
root:/tmp>sed 's/\([0-9]\)/\1.6789/g' num
1.6789
2.6789
3.6789
4.6789
5.6789
6.6789
7.6789
8.6789
root:/tmp>
1
2
3
4
5
shell
7
8
root:/tmp>
7
8.shell
root:/tmp>
1
2
3
4
5
root:/tmp>sed '1,5s/3/3.linux/g' num
1
2
3.linux
4
5
6
7
8
root:/tmp>sed -n '3,/^6/p' num
3
4
5
6
root:/tmp>
1******Total********
2******Total********
3******Total********
4******Total********
5******Total********
6
7
8
root:/tmp>
【转】sed 的参数的更多相关文章
- linux sed命令参数及用法详解
linux sed命令参数及用法详解 http://blog.csdn.net/namecyf/article/details/7336308 1. Sed简介 sed 是一种在线编辑器,它一次处理一 ...
- sed命令参数之-r -i
对于初学linux的朋友来说,能记住命令附带的一大帮参数就以及非常不容易了.好不容易把该用的参数都想全了.sed -irns 后面一大片脚本 ,一执行出错了 what!!!! 创建一下测试环境 hea ...
- linux sed命令详解
简介 sed 是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的 ...
- sed用法
简介 sed 是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的 ...
- 运维工作中sed常规操作命令梳理
sed是一个流编辑器(stream editor),一个非交互式的行编辑器.它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为"模式空间",接着用sed命令处理缓冲 ...
- sed 4个功能
[root@lanny test]# cat test.txt test liyao lanny 经典博文: http://oldboy.blog.51cto.com/2561410/949365 h ...
- Linux之Sed命令详解(总结一些实用例子)
简介 sed 是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的 ...
- Shell之sed用法 转滴
通过例子学习sed的用法 1,sed介绍 sed可删除(delete).改变(change).添加(append).插入(insert).合.交换文件中的资料行,或读入其它档的资料到 文> ...
- Linux之sed命令详解
简介 sed 是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的 ...
随机推荐
- Vue2.0 相对于Vue1.0的变化:生命周期
1.生命周期 根据提供的生命周期钩子说明Vue.js实例各个阶段的情况,Vue.js 2.0对不少钩子进行了修改,以下说明:(灰色字体代表是 2.0已经废弃或者被更名的钩子,黑色字体代表1.0 和2. ...
- 基础Linux命令总结
简单命令Linux ls 列出当前文件目录下的文件(只显示文件名) pwd 显示当前操作的路径 cd 跳转路径 ls -a 可以把隐藏的文件显示出来 ,另外,创建隐藏文件的命令是 touch.123. ...
- VirtualBox5虚拟机 安装ubuntu16.04
其实这是一个伪标题,因为主要的重心不是安装这个系统,而是怎样让它全屏显示! 自己想在ubuntu下装个Pycharm玩python,因此需要一个ubuntu系统镜像,好吧,找路子去下载,但是别下各种来 ...
- Codefoces 723B Text Document Analysis
B. Text Document Analysis time limit per test:1 second memory limit per test:256 megabytes input:sta ...
- 【Java数据结构学习笔记之一】线性表的存储结构及其代码实现
应用程序后在那个的数据大致有四种基本的逻辑结构: 集合:数据元素之间只有"同属于一个集合"的关系 线性结构:数据元素之间存在一个对一个的关系 树形结构:数据元素之间存在一个对多个关 ...
- 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 F. Trig Function(切比雪夫多项式+乘法逆元)
题目链接:哈哈哈哈哈哈 _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ 哈哈哈哈哈哈,从9月16日打了这个题之后就一直在补这道题,今天终于a了,哈哈哈哈哈哈. ...
- BZOJ1786: [Ahoi2008]Pair 配对/1831: [AHOI2008]逆序对
这两道题是一样的. 可以发现,-1变成的数是单调不降. 记录下原有的逆序对个数. 预处理出每个点取每个值所产生的逆序对个数,然后dp转移. #include<cstring> #inclu ...
- hdu_1033(我怎么找到的这么水的题,只为保存代码。。。)
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> us ...
- poj_2503(map映射)
题目链接poj2503 Babelfish Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 38820 Accepted: ...
- Unity Instantiate各函数执行顺序
GameObject go = Instantiate(aaa) ; go.GetComponent<NewBehaviourScript>().Init(); Instan ...