
sed
successdd
这个作者很懒,什么都没留下…
展开
-
10. Sed正则表达式
^$.[][^][-] 区间\? -E 的时候不需要\\+ -E 的时候不需要 \*{n} 或者 {n,}| \ 转义字符\r\nPOSIX 类型的的正则[:alnum:][:alpha:][:blank:][:digit:][:lower:] … 我觉得用不到 我反正我是不怎么用 元字符 含义原创 2018-01-16 19:35:27 · 307 阅读 · 0 评论 -
11. Sed 例子
去除代码中的注释dingmac@ubuntu:~$ echo -e "One\nTwo One\n#One\n//zhang" | sed -E 's@(//.*|#.*)@ ---- @' 打印出行数 类似wc -l seq 129 | sed -n '$='答应出前几行 head 10seq 120 | sed '10 q'打印出最后一行seq 102 | sed -n '$p'打原创 2018-01-17 10:26:24 · 173 阅读 · 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 · 215 阅读 · 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 · 483 阅读 · 0 评论 -
5. Sed 模式
sed -n '/The/,$ p' books.txt从 The 开始到最后一行打印出来sed -n '/Two/, +4 p' books.txt #这个就不解释了 打印出后面的4行原创 2018-01-16 18:59:25 · 175 阅读 · 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 · 185 阅读 · 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 · 897 阅读 · 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 · 282 阅读 · 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 · 206 阅读 · 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 · 176 阅读 · 0 评论 -
3 .Sed Loop
LOOP 类似于goto we can define a label as follows::label :start :end :upIn the above example, a name after colon(:) implies the label name.:label的形式就是一个labelTo jump to a specific label, we原创 2018-01-16 18:57:40 · 422 阅读 · 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 · 837 阅读 · 0 评论