[ale] stripping filename extension in bash

Christopher Bergeron christopher at bergeron.com
Sun Dec 1 00:09:01 EST 2002


Sweet!  Thanks for all the help!  I used the first suggestion (thanks 
Jason!) in my script, but I learned all about basename which is an 
extremely useful utility.

Thanks again guys!!!

-CB


Danny Cox wrote:

>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.
>
>  
>


_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale






More information about the Ale mailing list