[ale] stripping filename extension in bash
Danny Cox
danscox at mindspring.com
Sat Nov 30 23:51:31 EST 2002
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
More information about the Ale
mailing list