These two sed commands,
will do the same job. Let me explain how..
will replace all the characters from
- to the last character with an empty string. If a line don't have any
- character then the replacement won't occur. That is, it won't affect the lines which don't have the hyphen
will first search for the lines which have the
- symbol. If it finds any, then it will do the replacement (replaces all the characters from
- to the last character with an empty string) on those lines.
So both are the same. Your first sed command would be enough. You don't need to put the search condition. Also, since
- is not a special character, you don't need to escape it.