sed '/pattern/{p;s/pattern/replacement/}' input_fileExplanation:
/pattern/: This specifies the pattern that identifies the line you want to duplicate and modify.{p;s/pattern/replacement/}: This is a group of commands enclosed within {}.- p is used to print the line as it is, and
- s/pattern/replacement/ is used to substitute the pattern with the replacement string.
sed '/pattern/,$d' input_fileExplanation:
/pattern/,$: This specifies a range from the line containing the pattern to the end of the file ($).d: This command deletes the range specified.