linux sed命令参数及用法详解 http://blog.csdn.net/namecyf/article/details/7336308 1. Sed简介 sed 是一种在线编辑器,它一次处理一行内容.处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕.接着处理下一行,这样不断重复,直到文件末尾.文件内容并没有 改变,除非你使用重定向存储输出.Sed主要用来自动编辑一个或多个文件:
格式: sed -i "s/查找字段/替换字段/g" `grep 查找字段 -rl 路径` linux sed 批量替换多个文件中的字符串 sed -i "s/oldstring/newstring/g" `grep oldstring -rl yourdir` 例如:替换/home下所有文件中的www.admin99.net为admin99.net sed -i "s/www.admin99.net/admin99.net/g" `grep w
learn Linux sed command 一.参考文档: . sed命令详解 http://qifuguang.me/2015/09/21/sed%E5%91%BD%E4%BB%A4%E8%AF%A6%E8%A7%A3/ . linux之sed用法 http://www.cnblogs.com/dong008259/archive/2011/12/07/2279897.html . Sed 的man手册参数详细解释(一) http://blog.csdn.net/imfinger/arti
原文地址:https://www.systemcodegeeks.com/shell-scripting/bash/linux-sed-examples/?ref=dzone Sed is basically a stream editor used for modifying files in unix or linux. It provides a nifty way to perform operations on files which can be passed around thro
sed也成stream editor,流编辑器,是Linux上常用的文本处理工具. 通用格式:sed 行范围 模式/RegExp/ 文件 模式: d 删除 p 打印符合条件的行 a \string 追加显示(后行) i \string 追加显示(前行) r 在某行后插入另一个文本 w 保存到另一个文件 s/pattern/string/ 查找并替换(只替换每行第一个) s/pattern/string/g 全局替换 1.将test.txt第三行替换为hello输出: #!/bin/bash
sed -e 4a\newLine testfile 首先查看testfile中的内容如下: $ cat testfile #查看testfile 中的内容 HELLO LINUX! Linux is a free unix-type opterating system. This is a linux testfile! Linux test 使用sed命令后,输出结果如下: $ sed -e 4a\newline testfile #使用sed 在第四行后添加新字符串 HELLO LINUX