当前位置:网站首页>Perl command batch replaces some contents in the file
Perl command batch replaces some contents in the file
2022-07-19 13:26:00 【Learn programming notes】
perl The command can replace some contents in the file in batch , The operation is very efficient . Here are a few examples :
perl -pi -e "s/aaa/bbb/gi" test.txt
- The order above puts test.txt The characters in the file aaa Replace with bbb
perl -pi.bak -e "s/aaa/bbb/gi" test.txt
- The order above puts test.txt The characters in the file aaa Replace with bbb, And generate a test.txt.bak Backup files for
find ./ -name "*.txt" | xargs perl -pi.bak -e "s/aaa/bbb/gi"
- The above command will all the files in the current directory .txt The characters in the file aaa Replace with bbb, And generate the corresponding .bak Backup files for
Be careful : If it's a mistake can‘t do inpalce without backup , Please implement the second scheme , in the light of window Verified .
-p tell Perl Traverse the file name parameter added later , Roughly and sed The effect of this code in is similar to
-i It is generally used for backup operation when reading files .
-e tell Perl Keep up perl sentence
-p and -i Can be put together -pi,-p -e Can also be together , however -i,-e Can't write together -ie.
边栏推荐
- Li Kou 413 division of equal difference sequence dynamic programming
- Li Kou 198-213 looting Ⅰ, Ⅱ - Dynamic Planning
- Google developer community sharing - flutter animation sharing has been released
- 名片管理的框架搭建
- (pc+wap) dream weaving template clothing dress website
- 【Pygame 学习笔记】7.事件
- Audio common terminal anatomy - never make a mistake again
- 如何优雅的升级 Flink Job?
- 【错误记录/selectpicker】dropdown menu显示位置出现偏移
- Azkaban 安装文档
猜你喜欢

松下A6伺服驱动器外部绝对值光栅尺全闭环参数设置

codeforce:G. Good Key, Bad Key【贪心】

Audio common terminal anatomy - never make a mistake again

C语言进阶——字符函数和字符串函数

Uio-66 | fe3o4/cu3 (BTC) 2 metal organic framework (MOF) nanocomposites supported on silver nanoparticles | nagdf4:yb, er upconversion nanoparticles @zif-8

codeforce:A. Difference Operations【数学思维】

稳超胜算,历9弥新 | 2022金仓创新产品发布会顺利召开
![Code after annotation of hands-on deep learning (Second Edition) [continuous update]](/img/4a/726a2103817aa4bdb86d1d8eeabce9.jpg)
Code after annotation of hands-on deep learning (Second Edition) [continuous update]

可视化ETL工具Kettle概念、安装及实战案例

Stable super odds, 9 years old mixin | 2022 Jincang innovative product launch was successfully held
随机推荐
Wrong again, byte alignment and the use of pragma pack
STL string复制比较
mysql排序索引失效?
Copper sulfide nanoparticles /zif-8 Composites( [email protected] Support) | uio-66/coso composite | zif-67 nanocrystalline sur
[C language programming 7] BTB model
面试官:可以接受转Go吗?
565.数组嵌套
最懂你的服装设计师是AI?让用户 “凭心意” 生成数字服装#Adidas OZWORLD
codeforce:G. Good Key, Bad Key【贪心】
A general memory management driver code is sorted out
MySQL sort index failure?
XML文件解析
Google developer community sharing - flutter animation sharing has been released
Computer dial-up Internet access
【错误记录/selectpicker】dropdown menu显示位置出现偏移
Code after annotation of hands-on deep learning (Second Edition) [continuous update]
Li Kou 413 division of equal difference sequence dynamic programming
音频常见端子剖析图---再也不会搞错了
Advanced C language -- custom type: structure enumeration Union
Equivalent domain name