I need to recursively find all files with this HTML:
<html id="blx-5fb3c619e82a2863d6567c52-000000001" class="blx-5fb3c619e82a2863d6567c52"><head>
<meta charset="utf-8">
<meta name="google" value="notranslate">
And replace it with this HTML:
<html id="blx-5fb3c619e82a2863d6567c52-000000001" class="blx-5fb3c619e82a2863d6567c52"><head>
<meta charset="utf-8">
<meta name="google" value="notranslate">
<meta name="format-detection" content="telephone=no">
<meta name="format-detection" content="date=no">
<meta name="format-detection" content="address=no">
<meta name="format-detection" content="email=no">
This is my unsuccessful attempt of a grep command piped to a sed:
grep --include="index.html" -PRwzl -e '<html id="blx-5fb3c619e82a2863d6567c52-000000001" class="blx-5fb3c619e82a2863d6567c52"><head>\n <meta charset="utf-8">\n <meta name="google" value="notranslate">\n' | xargs -i@ sed -i 's/<html id="blx-5fb3c619e82a2863d6567c52-000000001" class="blx-5fb3c619e82a2863d6567c52"><head>\n <meta charset="utf-8">\n <meta name="google" value="notranslate">\n/<html id="blx-5fb3c619e82a2863d6567c52-000000001" class="blx-5fb3c619e82a2863d6567c52"><head>\n <meta charset="utf-8">\n <meta name="google" value="notranslate">\n <meta name="google" value="notranslate">\n <meta name="format-detection" content="telephone=no">\n <meta name="format-detection" content="date=no">\n <meta name="format-detection" content="address=no">\n <meta name="format-detection" content="email=no">\n/g' @
The grep command alone works perfectly.
For clarity, here is the command split into many sections.:
grep --include="index.html" \
-PRwzl \
-e '<html id="blx-5fb3c619e82a2863d6567c52-000000001" class="blx-5fb3c619e82a2863d6567c52"><head>
\n <meta charset="utf-8">
\n <meta name="google" value="notranslate">
\n' \
| xargs -i@ sed -i 's/<html id="blx-5fb3c619e82a2863d6567c52-000000001" class="blx-5fb3c619e82a2863d6567c52"><head>
\n <meta charset="utf-8">
\n <meta name="google" value="notranslate">
\n
/<html id="blx-5fb3c619e82a2863d6567c52-000000001" class="blx-5fb3c619e82a2863d6567c52"><head>
\n <meta charset="utf-8">
\n <meta name="google" value="notranslate">
\n <meta name="google" value="notranslate">
\n <meta name="format-detection" content="telephone=no">
\n <meta name="format-detection" content="date=no">
\n <meta name="format-detection" content="address=no">
\n <meta name="format-detection" content="email=no">
\n
/g' @