![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
sed
successdd
这个作者很懒,什么都没留下…
展开
-
10. Sed正则表达式
^ $ . [] [^] [-] 区间 \? -E 的时候不需要\ \+ -E 的时候不需要 \ * {n} 或者 {n,} | \ 转义字符 \r \n POSIX 类型的的正则 [:alnum:] [:alpha:] [:blank:] [:digit:] [:lower:] … 我觉得用不到 我反正我是不怎么用 元字符 含义原创 2018-01-16 19:35:27 · 280 阅读 · 0 评论 -
11. Sed 例子
去除代码中的注释 dingmac@ubuntu:~$ echo -e "One\nTwo One\n#One\n//zhang" | sed -E 's@(//.*|#.*)@ ---- @' 打印出行数 类似wc -l seq 129 | sed -n '$=' 答应出前几行 head 10 seq 120 | sed '10 q' 打印出最后一行 seq 102 | sed -n '$p' 打原创 2018-01-17 10:26:24 · 141 阅读 · 0 评论 -
1.Sed 初识
Sed 指的是 Stream Editor SED can be used in many different ways, such as: Text substitution, 文字替换 Selective printing of text files, 选择性答应text 文档 In-a-place editing of text files, 编辑文档 Non-interactive原创 2018-01-16 18:55:48 · 179 阅读 · 0 评论 -
4. Sed 行数控制
sed -n ‘1d’ files 就是删除第一行 ‘2,5p’ 表示 prints all the lines from 2 to 5 ($) which represents the last line of the file ‘2,+4 p’ books.txt 从第二行开始打印出后面4行 ‘M~n’ 50~5 matches line number 50, 55, 60, 6原创 2018-01-16 18:58:40 · 439 阅读 · 0 评论 -
5. Sed 模式
sed -n '/The/,$ p' books.txt 从 The 开始到最后一行打印出来 sed -n '/Two/, +4 p' books.txt #这个就不解释了 打印出后面的4行原创 2018-01-16 18:59:25 · 142 阅读 · 0 评论 -
2. Sed 语法初步
sed [-n] [-e] 'command(s)' files sed [-n] -f scriptfile files 可以写在 文件中使用 sed -f scriptfile files 这样的格式调用 在scriptfile中最后一个命令 写一行 类似于执行 sed -e 'commad1' -e 'commad2' files 或者 sed 'commad1;commad2' fi原创 2018-01-16 18:56:33 · 150 阅读 · 0 评论 -
6. Sed 基本操作符
d 删除 w write 写入到文件 a append 在某一行 跟随某一个 [jerry]$ sed '4 a 7) Adultry, Paulo Coelho, 234' books.txt 得到的结果: 1) A Storm of Swords, George R. R. Martin, 1216 2) The Two Towers, J. R. R. T原创 2018-01-16 18:59:52 · 842 阅读 · 0 评论 -
7.Sed 特殊操作符
= 显示当前的行号 [jerry]$ sed '=' books.txt On executing the above code, you get the following result: 1 1) A Storm of Swords, George R. R. Martin, 1216 2 2) The Two Towers, J. R. R. Tolkien, 352原创 2018-01-16 19:01:22 · 241 阅读 · 0 评论 -
8.Sed 替换
s [jerry]$ sed 's/,/ | /' books.txt 替换 On executing the above code, you get the following result: 1) A Storm of Swords | George R. R. Martin, 1216 2) The Two Towers | J. R. R. Tolkien, 352 3原创 2018-01-16 19:07:06 · 177 阅读 · 0 评论 -
9. Sed manage Pattern
参考 http://man.linuxde.net/sed - x - h - And curly braces {} are used to group multiple SED commands 下面的都是摘抄自 http://man.linuxde.net/sed 仅帮助回忆 具体查看man - a\ 在当前行下面插入文本。 有\ 表示将增加的内容 另起一行原创 2018-01-16 19:28:19 · 150 阅读 · 0 评论 -
3 .Sed Loop
LOOP 类似于goto we can define a label as follows: :label :start :end :up In the above example, a name after colon(:) implies the label name. :label的形式就是一个label To jump to a specific label, we原创 2018-01-16 18:57:40 · 370 阅读 · 0 评论 -
12. sed 替换 增强版
原文 https://www.thegeekstuff.com/2009/09/unix-sed-tutorial-replace-text-inside-a-file-using-substitute-command/?utm_source=sitekickr&utm_medium=snip_button 语法Syntax:#sed 'ADDRESSs/REGEXP/REPLACEMENT/FLA翻译 2018-01-17 12:02:39 · 758 阅读 · 0 评论