Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 4th, 2012  |  syntax: None  |  size: 0.57 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # Usage
  2. # (Note: This command does not handle spaces in filenames!)
  3. # * cd into the directory containing the files and subdirectories of files in
  4. #   which you wish to carry out string substitution using a regex
  5. # * Run the command:
  6. #   rsub 'search regex' 'replacement text'
  7. # * This will effect the desired substitution in files in the current directory
  8. #   and in any subdirectories
  9.  
  10. # Explaination
  11. # * The -I {} allows you to grab each thing that xargs iterates over
  12. #   as {}
  13. # * So {} is probably the most important thing
  14. #
  15. egrep -rl "$1" .|xargs -I {} sed -i "s/$1/$2/g" {}