I am trying to automate the deployment of war files that are generated by our build server using maven. I need to be able to extract the project name from the war filename so I can rename the file before deploying it. (Because tomcat uses the filename as the default context path and I don't want the version to be in there)
The filenames are usually in the form
myproject-1.2.3-SNAPSHOT.war my-better-project-1.2.3-RELEASE.war my-fancy-project-1.2.3.war
- SNAPSHOT or RELEASE may or may not be included in the filename.
- One tricky part is to extract the project name when the project name includes dashes.
The result should be the project name without the version information:
myproject my-better-project my-fancy-project
How can I achieve this using bash and sed (or only bash)?