Answer the question
In order to leave comments, you need to log in
How to replace a phrase in a file in different folders?
phrase $GLOBALS["SLIDER_TOP"] = 17258; to $GLOBALS["PREIM_TOP"] = 3670; ?
on all subdomains there is a folder stolbiki-parkovochnye in it index.php how to make a replacement in all folders of the index.php file?
like this find
find ./*/public_html/stolbiki-parkovochnye -name "index.php" | But how can I make a replacement in the file?
or is it correct?
grep -irl '$GLOBALS["SLIDER_TOP"] = 17258;' ./ekb/public_html | xargs -IX sed -i 's|$GLOBALS["SLIDER_TOP"] = 17258;|$GLOBALS["PREIM_TOP"] = 3670; |' X
Answer the question
In order to leave comments, you need to log in
Read to the end at the beginning
find ./*/public_html/stolbiki-parkovochnye -type f -name 'index.php' -exec sed -i 's/\x24GLOBALS\[\x22SLIDER_TOP\x22\] = 17258\x3B/GLOBALS["PREIM_TOP"] = 3670;/g' {} \;
./*/public_html/stolbiki-parkovochnye
- from which folder the -type f
file -name 'index.php'
is - only the php index -exec
- execute with the found one sed -i 's/было/стало/g'
- zaenit in the stream and overwrite all found matches in the file '\x24 и \x22 и \x3B
I wrote this here{}
- the miracle you were looking for is the argument that you found the find it is substituted (part of exec) \;
- close the exec cat index.php
GLOBALS["PREIM_TOP"] = 3670;
sed -i
change to sed -e
mkdir ./tmp/backup
find./*/public_html/stolbiki-parkovochnye -type f -name 'index.php' -print0 | xargs -0 cp --parents --target-directory ./tmp/backup
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question