Sunday, July 22, 2007

unix shell is still one of my favorite

unix shell is so easy and powerful, just like vi.
It is always my favorite.
the following example shows how to change variable in unix shell to lower case and remove file extension

for f in *.shp
do
#change to lower case
file_name=`echo $f | sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'`
#remove file extension to use as table name
table_name=${file_name%\.*}
echo "table name: $table_name"
done<

No comments: