I need to recursively search directories and replace the string (say http: // development: port / URI ) with another (say http: // production: port / URI ) in all the files where it was found. Can anyone help?
It would be much better if the script could print the files that it modified and accept search / replace patterns as input parameters.
Sincerely.
Try the following:
find . -type f | xargs grep -l development | xargs perl -i.bak -p -e 's(http://development)(http://production)g'
Another approach with a bit more feedback:
find . -type f | while read file do grep development $file && echo "modifying $file" && perl -i.bak -p -e 's(http://development)(http://prodution)g' $file done
Hope this helps.
to find. -type f | xargs sed -is / pattern / replacement / g
, . ( ?)
, . , .
svn/cvs, .svn/.cvs, , . .svn, , find. - f | fgrep -v.svn | xargs sed -i 's/pattern/replacement/g'
zsh, . :.
zsh
sed -i 's:pattern:target:g' ./**
Source: https://habr.com/ru/post/1697425/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1697420/how-would-you-allow-users-to-edit-attachments-in-a-web-application&usg=ALkJrhhjYhx2btcTf-eYWQmTld9rSUkMuQIs there a way to use XmlSiteMapProvider in a WinForm / Console / VSTest application? - unit-testingProcess coordination in mod_perl under working MPM - multithreadingДанные виджетов через несколько контроллеров - rubyShould I use Wap for a cellular web page? - websiteWhy does Hibernate seem to be for short classes? - javaSQL Server Adapter for Rails - windowscompression library for c and php - cCalculation of matrix pseudo-inversion in C ++ - c ++Веб-службы или пользовательский протокол? - web-applicationsAll Articles