Search and replace with perl


/ Published in: Bash
Save to your folder(s)

Replace all the occurrences of a string with a replacement in the supplied files.


Copy this code and paste it in your HTML
  1. perl -pi -w -e 's/search/replace/g;' files
  2.  
  3. -e means execute the following line of code.
  4. -i means edit in-place
  5. -w write warnings
  6. -p loop
  7.  
  8. eg.
  9.  
  10. perl -pi -w -e 's/today/tomorrow/g;' dates*.txt

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.