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.
  • file, replace, find, web editor
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

 Remove Login History on Server

On the Linux systems there are three standard commands that show the information about last...

 Enable Browser Caching with .htaccess File

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

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

 Disable Network Manager on CentOS 6

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