Five directories in each index.html file must be replaced with title. sed -i '-es / name / NAME / g' index.html is what I know, but this command must be run in each directory. How to run this command recursively or depth. Hour I go through the options do not, it turns out.

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

find . -name index.html -print0 | xargs -0 sed -i 'ваш_паттерн' 

If you want to limit the nesting of directories, use -maxdepth (1 is the current directory, 2 is the first nesting level, etc.):

 find . -maxdepth 2 -name index.html -print0 | xargs -0 sed -i 'ваш_паттерн' 
  • On OS X does not work, on Linux I will not get soon. On OS X, even directly sed -i 's / site / mail / g' does not change. - 031071
  • one
    @ 031071, you can put the implementation of the sed program from the operating system gnu : apple.stackexchange.com/questions/195590/… // // this implementation "understands" the -i option - aleksandr barakin