1. 已有的命令
格式: sed -i "s/查找字段/替换字段/g" `grep 查找字段 -rl 路径`
linux sed 批量替换多个文件中的字符串: (此命令很强大)
sed -i "s/oldstring/newstring/g" `grep oldstring -rl yourdir`
解释一下:
-i 表示 inplace edit,就地修改文件
-r 表示recursive ,搜索子目录
-l 表示line number,输出匹配的文件名
例如:替换/home下所有文件中的www.xxx.net为xxx.net
sed -i "s/www.xxx.net/xxx.net/g" `grep www.xxx.net -rl /home`
exp:sed -i "s/shabi/$/g" `grep shabi -rl ./`
2、自己额外附加
2.1 将文件1.txt内的文字“garden”替换成“mirGarden”
# sed -i "s/garden/mirGarden/g" 1.txt //sed -i 很简单
2.2 将当前目录下的所有文件内的“garden”替换成“mirGarden”
## sed -i "s/garden/mirGarden/g" `ls` //其实也就是ls出多个文件名而已
3、 查询
1.Linux查找不以#开头的行的命令
如:cat /etc/vsftpd/vsftpd.conf | grep -v "#"
相关推荐
a very good linux sed manu.
linux sed命令详解
linux sed 命令详解 资源收集 linux sed 命令详解 资源收集
prompt$ sedsed --help usage: sedsed OPTION [-e sedscript] [-f sedscriptfile] [inputfile] OPTIONS: -f, --file add file contents to the ... -H, --htmlize converts sed script to a colorful HTML page
Linux Shell Scripting Cookbook shows you how to capitalize on all the aspects of Linux using the shell scripting language. This book teaches you how to use commands to perform simple tasks all the way...
Linux Shell Scripting Cookbook shows you how to capitalize on all the aspects of Linux using the shell scripting language. This book teaches you how to use commands to perform simple tasks all the way...
Learning Linux Shell Scripting covers Bash, GNU Bourne Again Shell, preparing you to work in the exciting world of Linux shell scripting. CentOS is a popular rpm-based stable and secured Linux ...
Linux Shell Scripting Cookbook shows you how to capitalize on all the aspects of Linux using the shell scripting language. This book teaches you how to use commands to perform simple tasks all the way...
replace-unicode-string: a small tool used to replace unicodes strings in unicode file ( when we use sed -i on windows, it would not work for string replacement on unicode file, so I wrote these tool)....
linux命令中Sed各种使用方式
sed各个参数详解,多重替换,重定向,linux shell脚本摘要
Because there is a natural progression in learning from grep to sed to awk, we will be covering all three programs, although the focus is on sed and awk. Sed and awk are tools used by users, ...
主要讲述linux的sed功能使用,sed的各种命令和功能的使用,仅供参考。
linux shell sed 使用详解 整理的很好。很不错的资源。写脚本全靠这个了。
Sed命令是linux下的一个非常有用的命令,特别是在shell脚本中经常会使用到他。 熟悉他你会觉得非常有趣哦! 1.sed -n '2'p filename 打印文件的第二行。 2.sed -n '1,3'p filename 打印文件的1到3行 3. sed -n '/...
linux 系统 sed 命令使用方法linux 系统 sed 命令使用方法linux 系统 linux 系统 sed 命令使用方法linux 系统 sed 命令使用方法sed 命令使用方法
文章主要介绍Linux下sed命令的用法,感兴趣的朋友可以看看。
SED单行脚本快速参考(Unix 流编辑器) sed命令使用说明
Linux三剑客之sed命令:自己在平时的使用过程中总结积累的sed命令的若干种常用用法,特分享出来。 参数: -i 表示inplace edit,就地修改文件 -r 表示搜索子目录 -l 表示输出匹配的文件名 s 表示替换,d 表示删除...
linux shell命令sed的使用方法