From d70db48add3d6e5fb4772b0deb3f14f019fc65a2 Mon Sep 17 00:00:00 2001 From: ThomasC Date: Mon, 14 Jun 2021 22:14:16 +0200 Subject: [PATCH] ajout fonctiondirMustContains --- functions.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/functions.sh b/functions.sh index e95c776..372cfaa 100644 --- a/functions.sh +++ b/functions.sh @@ -80,6 +80,21 @@ if [ -d ${1} ] ; then echo -ne "0;" fi } +# Ok if some files of given dir contains at least one occurence of pattern +# arg1: dir +# arg2: pattern +function dirMustContains { + dir=$1 + shift + string=$@ + if [ ! -d $dir ] ; then echo -ne "0;" ; return 0 ;fi + if ( grep -ri -qE "${string}" $dir ) ; + then echo -ne "1;" + else + echo -ne "0;" + fi +} + # Ok if file contains at least one occurence of pattern # arg1: file # arg2: pattern