Get the App
SLTechnology News&Howtos  ›  Development  › 

How to replace the contents of files in batch by Linux

Shulou Source: shulou.com Published: 2022-06-01 20:19:11 10月02日 Update

Most people do not understand the knowledge points of this article "Linux how to replace file content in batches", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Linux how to replace file content in batches" article.

Method 1 uses perl. The command is as follows:

Find-name 'File name to find' | xargs perl-pi-e's | replaced string | replaced string | g'

Method 2 uses the sed command as follows:

Sed-I "s / original string / new string / g" grep original string-directory where rl is located

Method 3 uses shell with the following command:

Grep "abc" *-R | awk-F:'{print $1}'| sort | uniq | xargs sed-I's Ligand

The above is about the content of this article on "how to replace document content in batches by Linux". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

Tags: Content characters strings files commands methods articles knowledge articles values most that is location file names more steps directories knowledge points industries information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Tech Info Shulou Technology Linux NVidia