Artificial intelligent assistant

sed - change lines that start with one given word and end with another? For example, given: $ cat test001.txt this is a test bucket bucket line not this one. bucket lein endy bucket and others endy and a ttest How can I change the lines that start with "bucket" with "(bucket", ignoring spaces? So far I have: sed -i 's/^\sbucket/bucket(/g' test001.txt but that doesn't work (no change and no error). Then I would like to only do it for lines that _also_ end with 'endy' (so only 2 of the 3 bucket lines).

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.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 3fc6a77795fa3d21e86f3f8bd1591ad3