From 3efa2ff81480be3a205f97aa5316ea122a71d35a Mon Sep 17 00:00:00 2001 From: Romain Date: Thu, 26 Oct 2023 14:12:27 +0200 Subject: [PATCH] continue regex exercice --- Regex/run | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Regex/run b/Regex/run index 372f502..9e6b613 100644 --- a/Regex/run +++ b/Regex/run @@ -12,11 +12,11 @@ regex2=$(cat student_regex2) regex3=$(cat student_regex3) regex4=$(cat student_regex4) -grep -oP $regex1 apache.log > student_result1 -grep -oP '(\d{1,3}\.){3}\d{1,3}' apache.log > good_result1 - global_success=true +grep -oP "$regex1" apache.log > student_result1 +grep -oP '(\d{1,3}\.){3}\d{1,3}' apache.log > good_result1 + if diff student_result1 good_result1; then feedback-result --id regex1 success feedback-msg -e -m "Correct" --id regex1 @@ -26,7 +26,7 @@ else global_success=false fi -grep -oP $regex2 apache.log > student_result2 +grep -oP "$regex2" apache.log > student_result2 grep -oP '\[.*?\]' apache.log > good_result2 if diff student_result2 good_result2; then @@ -38,7 +38,7 @@ else global_success=false fi -grep -oP $regex3 apache.log > student_result3 +grep -oP "$regex3" apache.log > student_result3 grep -oP '"GET\s.*?"' apache.log > good_result3 if diff student_result3 good_result3; then @@ -50,7 +50,7 @@ else global_success=false fi -grep -oP $regex4 apache.log > student_result4 +grep -oP "$regex4" apache.log > student_result4 grep -oP '^.*200.*$' apache.log > good_result4 if diff student_result4 good_result4; then @@ -62,6 +62,8 @@ else global_success=false fi +echo $global_success + if [ $global_success ]; then feedback-result success feedback-msg -em "Bravo, vous avez réussi"