Here's another approach:
sed -e '/^[[:space:]]*bucket.*endy$/s/bucket/(bucket/' file.txt
The initial `/pattern/` tells sed to only work on lines containing that `pattern`, and the rest of it is a simple, standard substitution.
Here's another approach:
sed -e '/^[[:space:]]*bucket.*endy$/s/bucket/(bucket/' file.txt
The initial `/pattern/` tells sed to only work on lines containing that `pattern`, and the rest of it is a simple, standard substitution.