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 .htaccess File

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

View Server PHP Environment with phpinfo.php

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...

How to Change Root Password Using SSH

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

Enable Browser Caching with cPanel Includes Editor

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