Artificial intelligent assistant

How can I replace a filename with .ear in a file-list using sed? I have a file whose contents look like: /appl/as/var/spool/ears/mps/ear1.ear ... I want to replace the name of only `ear1.ear` with `ear2.ear` and I am using the below `sed` command, but with no luck: sed -i.bak s/*.ear/ear2.ear/g earlist.mps where `earlist.mps` is the file name I have tried: sed -i.bak s/.*.ear/ear2.ear/g earlist.mps but this replaces the whole file with `ear2.ear`.

With `sed`:


sed 's|/[^/]\+\.ear$|/ear2.ear|' file


* It seaches for line ending with `.ear` (`$` matches the end of the line). The filename can be everything except a `/`: `[^/]\+`. The `+` indicates that a character (which is not a `/`) can be repreated 1 or more times.
* Then is replaces that match with `/ear2.ear`.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 415529b33f6d103a832a3dc703bf3a42