[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] stripping filename extension in bash
- Subject: [ale] stripping filename extension in bash
- From: danscox at mindspring.com (Danny Cox)
- Date: 30 Nov 2002 23:51:31 -0500
Chris,
On Sat, 2002-11-30 at 15:45, Christopher Bergeron wrote:
> Does anyone know how I can strip the extension from a filename in a bash
> script?
>
The "traditional" way is to use 'basename'. It will also remove any
preceding directory names. But, if you include an extension to strip,
it'll remove that too:
I=xyzzy.jpg
echo $(basename "$I" .jpg)
will echo "xyzzy".
Of course, there are many ways to do what you want, as witnessed by the
other suggestions.
--
kernel, n.: A part of an operating system that preserves the
medieval traditions of sorcery and black art.
Danny
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale