I use the sed
command on macOS with the following text:
$ cat pets.txt
This is my cat
my cat's name is betty
This is your dog
your dog's name is frank
This is your fish
your fish's name is george
This is my goat
my goat's name is adam
When I run BSD sed
it shows an error:
$ sed '/dog/,+3s/^/# /g' pets.txt
sed: 1: "/dog/,+3s/^/# /g": expected context address
What's wrong with it? When I use gsed
(GNU sed), it works well:
This is my cat
my cat's name is betty
# This is your dog
# your dog's name is frank
# This is your fish
# your fish's name is george
This is my goat
my goat's name is adam