Linux find and replace text within all files within a directory



There is a fast way to replace all the occurrences of one world within a certain directory including subdirectory by using a one line Linux code (by using Perl):



find /path/to/start/from/ -type f | xargs perl -pi -e 's/old_word/new_word/g'





REMEMBER ALWAYS BACKUP BEFORE DOING SOMETHING
If you want to do word replacement using the vim
:%s/search/replace/g                     whole file
:2,12s/search/replace/g                 from line 2 to line 12

No comments:

Post a Comment

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...