Re: cut
- From: "Chris F.A. Johnson" <cfajohnson@xxxxxxxxx>
- Date: Fri, 27 Oct 2006 16:17:57 -0400
On 2006-10-28, virus.clear.net.nz wrote:
If I have a listing of packages,
such as : -
XML-Parser-2.34.tbz2
bin86-0.16.17.tbz2
libxml2-2.6.26.tbz2
system-tools-backends-1.4.2.tbz2
I want to cut the version number from the listing, leaving only bin86,
libxml2, etc.
I think that cutting a "-" followed by a {0-9} achieve this ??? but cut
only allows for a single delimiter.
How to achieve this ?
If you have the name in a variable:
pkg=bin86-0.16.17.tbz2
echo ${pkg%-[0-9]*}
If it's in a file or other list, pipe it through sed:
sed 's/\(.*\)-[0-9].*/\1/'
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
.
- References:
- cut
- From: virus.clear.net.nz
- cut
- Prev by Date: Re: cut
- Next by Date: Re: scripting help
- Previous by thread: Re: cut
- Next by thread: Re: cut
- Index(es):
Relevant Pages
|