I cannot seem to figure out how to come up with the correct regex for my bash command line. Here's what I am doing:
echo "XML-Xerces-2.7.0-0.tar.gz" | sed -e's/^\(.*\)-[0-9].*/\1/g'
This gives me the output of ...
XML-Xerces-2.7.0
... but want I need is the output to be ...
XML-Xerces
... I guess I could do this ...
echo "XML-Xerces-2.7.0-0.tar.gz" | sed -e's/^\(.*\)-[0-9].*/\1/g' | sed -e's/^\(.*\)-[0-9].*/\1/g'
... but I would like to know how understand sed
regex a little better.
Update:
I tried this ...
echo "XML-Xerces-2.7.0-0.tar.gz" | sed -e's/^\([^-]*\)-[0-9].*/\1/g'
... as suggest but that outputs XML-Xerces-2.7.0-0.tar.gz