From c963535b41f55a5aa89273f8bc16447aeb866e55 Mon Sep 17 00:00:00 2001 From: pvincent Date: Mon, 6 Jun 2022 13:39:39 +0400 Subject: [PATCH] append_or_replace full regex --- tools/append_or_replace | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/append_or_replace b/tools/append_or_replace index 7772383..ebf5320 100755 --- a/tools/append_or_replace +++ b/tools/append_or_replace @@ -13,10 +13,10 @@ REGEX=$1 STRING=$2 FILE=$3 -if ! grep -Pq "$REGEX" "$FILE"; then +if ! grep -Eq "$REGEX" "$FILE"; then printf "%s\n" "$STRING" >>$FILE echo appended else - sed -i "s|$REGEX|$STRING|g" $FILE + sed -Ei "s|$REGEX|$STRING|g" $FILE echo replaced fi