>From 7285a66bb31b1a2d6b4c93ba77e3e13f975ae7fa Mon Sep 17 00:00:00 2001 From: kitsunyan Date: Sun, 14 Feb 2021 20:08:16 +0300 Subject: [PATCH] Speedup batch replace using parallel find+sed Allow to specify NPROC environment variable to use multiprocessing for heavy batch replace operations. --- makeicecat | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/makeicecat b/makeicecat index 284394e..205582d 100755 --- a/makeicecat +++ b/makeicecat @@ -469,9 +469,9 @@ s|https://www\\.mozilla\\.org/icecat/?utm_source=synceol|https://www.mozilla.org s|www\\.gnu\\.org/software/gnuzilla/icecat-help|libreplanet.org/wiki/Group:IceCat/Help|g; " - find . -type f -not -iregex '.*changelog.*' -not -iregex '.*copyright.*' -not -iregex '.*third_party/rust.*' -execdir /bin/sed --follow-symlinks -i "${sed_script}" '{}' ';' + find . -type f -not -iregex '.*changelog.*' -not -iregex '.*copyright.*' -not -iregex '.*third_party/rust.*' -print0 | xargs -0 -P "${NPROC:-1}" -i /bin/sed --follow-symlinks -i "${sed_script}" '{}' - find l10n -type f -execdir /bin/sed --follow-symlinks -i "s/from GNU/from Mozilla/g" '{}' ';' + find l10n -type f -print0 | xargs -0 -P "${NPROC:-1}" -i /bin/sed --follow-symlinks -i "s/from GNU/from Mozilla/g" '{}' sed_script=" s/free and open source software/Free Software/g; @@ -485,7 +485,7 @@ s/OpenSource/Free Software/g; local extension for extension in dtd ftl inc properties; do - find . -type f -name "*$extension" -execdir /bin/sed --follow-symlinks -i "${sed_script}" '{}' ';' + find . -type f -name "*$extension" -print0 | xargs -0 -P "${NPROC:-1}" -i /bin/sed --follow-symlinks -i "${sed_script}" '{}' done sed 's/which are both/which are/; s/free<\/a> and/Free Software<\/a>./; />open source