Extract RPM name from path to .rpm file

It's the end of the day and I just can't get my head around this. I'm trying to extract just the name of the RPM from the path to a .rpm file. So from:

/home/me/rpm/RPMS/i386/nagios-our-plugins-1.2-6.i386.rpm

I need to extract 'nagios-our-plugins'.

I can't get the awk syntax right:

awk '{ split($STUFF, a, "-") print $a[1] }'

(where $STUFF is a bash variable that contains the path).

Can anyone help me out with a awk, sed or even straight bash script to do this?

A solution with sed :

$ echo /home/me/rpm/RPMS/i386/nagios-our-plugins-1.2-6.i386.rpm | sed 's_.*/\([^.]*\).*_\1_'
nagios-our-plugins-1
$

Jean-Pierre.

There's no need for an external command. In any POSIX shell:

path=/home/me/rpm/RPMS/i386/nagios-our-plugins-1.2-6.i386.rpm
rpm=${path##*/}
name=${rpm%%-[0-9]*}

Thanks, the below worked perfectly:
path=/home/me/rpm/RPMS/i386/nagios-our-plugins-1.2-6.i386.rpm
rpm=${path##/}
name=${rpm%%-[0-9]
}

Hi,

Please help, Input file is on Linux box and the input file has data in just one line with 1699741696 characters.

Sample Input:
<xml><document coll="uspatfull" version="0"><CMSdoc>xxxantivirus <tag1>1</tag1></CMSdoc></document><document coll="uspatfull" version="0"><CMSdoc>yyy<tag1> a</tag1></CMSdoc></document>><document coll="uspatfull" version="0"><CMSdoc>likeavirusesxxx<tag1>aaa</tag1></CMSdoc></document></xml>

Output should be:
If data like "virus" appears anywhere between the document tags we need that in the output.

<xml><document coll="uspatfull" version="0"><CMSdoc>xxxantivirus <tag1>1</tag1></CMSdoc></document><document coll="uspatfull" version="0"><CMSdoc>likeavirusesxxx<tag1>aaa</tag1></CMSdoc></document></xml>

Thanks!

Gaya,

Please do not add a new question on a different subject to an existing thread.
You should open a new thread instead.

Thanks