From 3615e907f5b8c35b3a68320b3e6bf1aa47ff09d2 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Mon, 2 Dec 2024 19:07:51 +0100 Subject: [PATCH] testing: Improve replacing IP addresses in test files There are a lot of files without patterns and running them all through sed is quite slow. Using grep first makes this quicker (about 0.5s per test). Ignoring PEM files is also helpful. --- testing/scripts/function.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/testing/scripts/function.sh b/testing/scripts/function.sh index 5fbc98293b..c162044e51 100755 --- a/testing/scripts/function.sh +++ b/testing/scripts/function.sh @@ -194,10 +194,6 @@ function searchandreplace { # search and replace in each found file the # given string # - - for eachfoundfile in `find $DESTDIR -type f` - do - sed -i -e "s/$SEARCHSTRING/$REPLACESTRING/g" "$eachfoundfile" - done - + grep -rlZ --exclude='*.pem' "$SEARCHSTRING" $DESTDIR | \ + xargs -0 -I@ sed -i -e "s/$SEARCHSTRING/$REPLACESTRING/g" @ } -- 2.47.3