Sed and Grep are different beats on macOS. To get similar equivalents install:
brew install ggrep # to invoke use ggrep
brew install gnu-sed # to invoke use gsed
brew install findutils # to invoke use gfind
That’s basically all there is on this, but it’s helpful to know, because it can save a lot of inter-OS retooling.
Here is a program to delete a line that matches a regex in gnu-sed:
#!/usr/bin/env bash
# Directory containing the files to modify
directory="./"
# Find all files in the directory and its subdirectories
find "$directory" -type f | while read -r file; do
# Check if the file path is absolute or relative
if [[ ! "$file" =~ ^/ ]]; then
# Make the path absolute
file="$directory/$file"
fi
# Use sed to remove the lines matching the patterns
# Note: The patterns are escaped to match exactly
gsed -E -i '/"created"\s*=\s*var\.creation_date,/d' "$file"
gsed -E -i '/"updated"\s*=\s*timestamp\(\),/d' "$file"
done
echo "Lines removed successfully."