[wplug] Checking the extension of a file in a shell script

Brandon Kuczenski brandon at 301south.net
Fri May 12 19:43:30 EDT 2006


On Fri, 12 May 2006, Eric Cooper wrote:

> On Fri, May 12, 2006 at 03:53:17PM -0400, O'Connor, Michael P. wrote:
>
>> Does any one know how to check for a final character on a string
>> (lets call it $file) I want to look to see if the last 2 chars are
>> ".C" this is csh,
>
> Check if "$file:e" (the extension) is equal to "C".
>

Damn, that's pretty sweet.  Does bash do anything like that?  I've been 
using echo $file | awk -F "." ' { print $NF }'

-brandon



More information about the wplug mailing list