Replace string in multiple files - Command line

Go to directory that contain files.

cd /var/www/posts

Find all PHP files in that folder & replace string foo with bar in all files.

find . -name "*.php" -print | xargs sed -i 's/foo/bar/g'

Recent Posts

  1. Solve Grunt error - Port 35729 is already in use by another process
  2. Install WP-CLI
  3. Install LAMP - Apache2 , MariaDB, PHP 7 on Debian 8
  4. Enable / Disable Magento 2 module using command line
  5. Disable WYSIWYG editor - Magento 2


Questions / Comments

If you found this article interesting, found errors, or just want to discuss about them, please get in touch. Send an email to hello@sarathlal.com & I like your words.