Recursive Find and Replace Command Line Method

Reference this guide for help with mass find and replace file manipulation in Linux servers.

Find and Replace text strings recursively through all files and sub-folders of a particular directory.

Run the following command from SSH terminal:

egrep -lRZ 'old-text-string' . | xargs -0 -l sed -i -e 's/old-text-string/new-text-string/g'

This command will recursively replace every instance of "old-text-string" with "new-text-string. Modify the command to best meet your needs.

Was this answer helpful?

 Print this Article

Also Read

Enable Browser Caching with cPanel Includes Editor

Enable browser caching to reduce website loading times, by taking advantage of caching of...

Disable Network Manager on CentOS 6

This article will provide the steps to disable Network Manager in CentOS 7. Network Manager is...

How to Change Root Password Using SSH

This article explains the method of changing the root password on a Linux Server using SSH. SSH...

Disable Network Manager on CentOS 7

This article will provide the steps to disable Network Manager in CentOS 7. Network Manager is...

How to Bind Additional IPs to Network Interface Card - CentOS

This article explains the process of binding multiple IP addresses to the Network Interface Card...