文件内容替换 :SED 命令 和 Perl
2013-06-13 16:28
218 查看
Linux文件内容替换
Perl
把文件file.txt中的before改为after
perl -pi -e 's/before/after/g' file.txt
-p 表示匹配文件的每一行
-i 表示把替换的结果写回到原文件
-e 表示后面的程序都写在一行上
SED
$ sed -i 's/ugly/beautiful/g' /home/bruno/old-friends/sue.txt
-i 记录的内容写回源文件
/s 替换命令
/g 全局替换
参考
http://www.brunolinux.com/02-The_Terminal/Find_and%20Replace_with_Sed.html
http://bbs.linuxtone.org/thread-1731-1-1.html
Perl
把文件file.txt中的before改为after
perl -pi -e 's/before/after/g' file.txt
-p 表示匹配文件的每一行
-i 表示把替换的结果写回到原文件
-e 表示后面的程序都写在一行上
SED
$ sed -i 's/ugly/beautiful/g' /home/bruno/old-friends/sue.txt
-i 记录的内容写回源文件
/s 替换命令
/g 全局替换
参考
http://www.brunolinux.com/02-The_Terminal/Find_and%20Replace_with_Sed.html
http://bbs.linuxtone.org/thread-1731-1-1.html
相关文章推荐
- 文件内容替换 :SED 命令 和 Perl
- linux批量替换文件内容3种方法(perl,sed,shell)
- 替换文件中指定的内容并保存之sed命令
- linux批量替换文件内容3种方法(perl,sed,shell)
- 用sed命令替换一个目录下全部文件的内容
- linux批量替换文件内容3种方法(perl,sed,shell)
- linux批量替换文件内容3种方法(perl,sed,shell)
- linux替换、截取文件内容的sed命令
- 请教大家,如何使用sed命令,替换文件指定行的内容呢?-Linux系统管理-ChinaUnix.net
- python 实现类似sed命令的文件内容替换
- linux批量替换文件内容3种方法(perl,sed,shell)
- sed命令实现文件内容替换总结案例
- 详解linux下批量替换文件内容的三种方法(perl,sed,shell)
- linux批量替换文件内容3种方法(perl,sed,shell)
- 【实用手记】使用sed命令替换指定文件内容
- linux批量替换文件内容3种方法(perl,sed,shell)
- sed命令 替换文件内容
- linux批量替换文件内容3种方法(perl,sed,shell)
- linux批量替换文件内容3种方法(perl,sed,shell)
- linux批量替换文件内容3种方法(perl,sed,shell)