Find and Replace command for ubuntu/Linux

Find and Replace sed command for Ubuntu/Linux Find and replace the occurrence of particular string in a directory or sub directory using below mention commands:

  • Search for the occurrence of the string in directory or sub-directory.
  • 
        grep -rl  . 2> /dev/null
        
  • Find and replace the occurrence of given string in a directory and its subdirectory, ex: Replace 'foo' with 'bar'.
  • 
        find . -exec sed -i -e 's/foo/bar/g' {} \;
        
  • Find and replace the occurrence of given string as website URL with given string in a directory and its subdirectory, ex: Replace 'http://www.example.com/foo' with 'bar'.
  • 
        find . -exec sed -i -e 's+http://www.example.com/foo+/bar+g' {} \;
        
-:END:-

Comments

Popular posts from this blog

How to setup Drupal 8 Multisite on nginx webserver with different domain.

Install drush globally using composer on WSL

Drupal views create exposed filter programmatically