1

So I want to match all below then remove those lines of string.

[MTT-5634](https://my.atlassian.net/browse/MTT-5634) [MCC-123](https://my.atlassian.net/browse/MCC-123) [MTT-7965]: https://my.atlassian.net/browse/MTT-7965 https://my.atlassian.net/browse/MTT-7965 

I have tried

sed -e 's/\[(MTT|MCC)-[0-9]{3,4}\?]\?://g;s!.\?http[s]\?://\S*!!g' input.txt > output.txt 
2
  • Please edit your question and show us more examples, including both lines that should be kept and lines that should be deleted. You seem to also want to find MCC- and apparently can have a variable list of numbers, but what else? And do you want to delete the line or keep it as an empty line?
    – terdon
    CommentedOct 10, 2022 at 10:15
  • I have updated it, to make more sense @terdon
    – Beelzebub
    CommentedOct 12, 2022 at 1:51

1 Answer 1

1

You didn't enable the -Extended regex, so you will need to escape a few special character such as (, ), |, {, }, ?. You also have a trailing : in your first sed statement that should be removed. Also, you forgot to escape the closing bracket ].

Your own corrected (but not improved) command should be:

sed -e 's/\[\(MTT\|MCC\)-[0-9]\{3,4\}\?\]\?//g;s!.\?http[s]\?://\S*!!g' infile 

See What characters do I need to escape when using sed in a sh script?

2
  • hello so -e and -E not same? Sorry I got confused
    – Beelzebub
    CommentedOct 10, 2022 at 8:50
  • @Beelzebub Hello. Of course they are not. see man sed for description of each.CommentedOct 10, 2022 at 11:51

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.