Browse Source

append_or_replace full regex

master
pvincent 2 years ago
parent
commit
c963535b41
  1. 4
      tools/append_or_replace

4
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
Loading…
Cancel
Save