testfile starts with:  abc: aprefixAnYthingasuffixThis sed operation is NOT working:sed -i 's/aprefix*asuffix/mynewword/g' testfiletestfile ends with:  abc: mynewwordhttp://regexone.com/lesson/line_beginning_end
How to replace word with unique prefix and suffix?
sed
Try: sed -i 's/aprefix.*asuffix/mynewword/g' testfile. .* means zero or more of any character; x* means zero or more of x, which would match aprefixxxxxxxxxxxxxxxasuffix, for example.Specifically, . is the regex wildcard for any one character, and * is regex-ese for zero or more of that last thing, so .* is regex-ese for any character followed by zero or more of any character(s).