Posted By

sanjivarunsahayamhotmailcom on 12/17/08


Tagged

Bash search replace perl


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

sulfurito
ascarion
noah


Search and replace with perl


 / Published in: Bash
 

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

  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  

You need to login to post a comment.