diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0d3997097a8b182d7dbefba18459280a41296c41..c2b2478090a617010b9f0c14ae4925d28da82773 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1355,7 +1355,7 @@ check-matlab-ols: $(M_OLS_TRS_FILES)
 %.m.trs %.m.log: %.mod
 	@echo "`tput bold``tput setaf 8`MATLAB: $(CURDIR)/$*... `tput sgr0`"
 # The while loop is a workaround for this glibc bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19329 (should be fixed in glibc 2.34, likely included in Debian “bookworm” 12)
-	@while ! [ -f $*.m.trs ] || head -1 $*.m.log | egrep -q '^Inconsistency detected by ld.so'; \
+	@while ! [ -f $*.m.trs ] || head -1 $*.m.log | grep -E -q '^Inconsistency detected by ld.so'; \
 	do \
 	DYNARE_VERSION="$(PACKAGE_VERSION)" TOP_TEST_DIR="$(CURDIR)" FILESTEM="$*" \
 		$(MATLAB)/bin/matlab $(MATLAB_BATCH_OPTIONS) run_test_matlab > $*.m.log 2>&1 || \
@@ -1374,7 +1374,7 @@ check-matlab-ols: $(M_OLS_TRS_FILES)
 %.m.trs %.m.log : %.m
 	@echo "`tput bold``tput setaf 8`MATLAB: $(CURDIR)/$*... `tput sgr0`"
 # The while loop is a workaround for this glibc bug: https://sourceware.org/bugzilla/show_bug.cgi?id=19329 (should be fixed in glibc 2.34, likely included in Debian “bookworm” 12)
-	@while ! [ -f $*.m.trs ] || head -1 $*.m.log | egrep -q '^Inconsistency detected by ld.so'; \
+	@while ! [ -f $*.m.trs ] || head -1 $*.m.log | grep -E -q '^Inconsistency detected by ld.so'; \
 	do \
 	DYNARE_VERSION="$(PACKAGE_VERSION)" TOP_TEST_DIR="$(CURDIR)" \
 		$(MATLAB)/bin/matlab $(MATLAB_BATCH_OPTIONS) $* > $*.m.log 2>&1 || \