[ale] stripping filename extension in bash

Christopher Bergeron christopher at bergeron.com
Sat Nov 30 15:45:08 EST 2002


Does anyone know how I can strip the extension from a filename in a bash 
script?

Here's my script:

#!/bin/bash
echo USE bergeron
for i in `\ls *.jpg`
do
echo "INSERT INTO pictures VALUES ('','$i','','','');"
done

When run, the script produces lines like this:

INSERT INTO pictures VALUES ('','dsc01072.jpg','','','');
INSERT INTO pictures VALUES ('','dsc01073.jpg','','','');

What i'd like to do is get $i without the .jpg extension at the end so 
it would read:

INSERT INTO pictures VALUES ('','dsc01072','','','');
INSERT INTO pictures VALUES ('','dsc01073','','','');

Does anyone have a simple awk or sed line to do this?

Thanks much!!!
-CB


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






More information about the Ale mailing list