The art of String manipulation in bash: Substring Removal


#!/bin/bash

stringZ=abcABC123ABCabc
# |----| shortest
# |----------| longest

#Deletes shortest match of $substring from front of $string.
echo ${stringZ#a*C} # 123ABCabc
# Strip out shortest match between 'a' and 'C'.

# ##a*c: Deletes longest match of $substring from front of $string, from a to longest C
echo ${stringZ##a*C} # abc
# Strip out longest match between 'a' and 'C'.
#src: http://tldp.org/LDP/abs/html/string-manipulation.html

echo ============================

echo "LINKING WEB MODULES"
WEBDIR="/opt/SUNWappserver/domains/domain1/autodeploy"

ADDONS_DIR=/usr/local/my/addons
ADDONS=`ls $ADDONS_DIR/*.war 2>/dev/null`
echo "addons:$ADDONS"
#if [[ "$ADDONS_DIR" ]]; then
for WARFILE in $ADDONS; do
echo $WARFILE
echo ${WARFILE##*/}
rm -f $WEBDIR/${WARFILE##*/} &>/dev/null
ln -s $WARFILE $WEBDIR/${WARFILE##*/}
echo {WARFILE##*/}:${WARFILE##*/}
done

How to copy only .war files in a folder to another folder(autodeploy)


# Create addons dir
ADDONS_DIR=/usr/local/somefolder/addons
if [ ! -d "$OS_ADDONS_DIR" ]; then
mkdir -p $OS_ADDONS_DIR
fi

ADDONS=`ls $ADDONS_DIR/*.war 2>/dev/null`
#if [[ "$ADDONS_DIR" ]]; then
for WARFILE in $ADDONS; do
rm -f $WEBDIR/${WARFILE##*/} &>/dev/null
ln -s $WARFILE $WEBDIR/${WARFILE##*/}
done

Supported language formatting:
http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi#Supported_languages

第194周周末中文竞赛 (2010年9月27日到2010年10月3日) 结果揭晓

Here is the winners list for last week:

国际中文实验室自2006年12月10日起,已成功举办194届网上周末中文竞赛(免费),来自
世界各地的中文学习爱好者参加了我们的每周中文竞赛。
第194周周末中文竞赛 (2010年9月27日到2010年10月3日) 结果已经揭晓。优胜者是:

Willie Jin, Richard Zhang, Laura L.

What is this line for?

Labor Day, Emory University. Several visitors stooping by asking what this line is for. End up being passport and visa applications as Chinese consulates from Houston stopped by. Pretty boring, huh?

Need more exercises

Sitting before a computer all day long. Definetely need more exercises!

I used to take a short walk around lunch time. But the outside is so hot I cannot do it now. Have to shift it to night while the weather is much cooler.