在ubuntu上写法有区别
使用
#!/bin/bash代替#!/bin/sh
否则if的时候会报
unexpected operator
rename的写法也不一样
使用
rename 's/aa/haohao/;' aa
代替
rename aa haohao aa
Bareword "DemoServer" not allowed while "strict subs" in use at (eval 1) line 1.
示例代码
使用
#!/bin/bash代替#!/bin/sh
否则if的时候会报
unexpected operator
rename的写法也不一样
使用
rename 's/aa/haohao/;' aa
代替
rename aa haohao aa
Bareword "DemoServer" not allowed while "strict subs" in use at (eval 1) line 1.
示例代码
#!/bin/bash
if [ $# -lt 3 ]
then
echo "<Usage: $0 App Server Servant>"
exit 0
fi
APP=$1
SERVER=$2
SERVANT=$3
if [ "$SERVER" == "$SERVANT" ]
then
echo "Error!(ServerName == ServantName)"
exit -1
fi
if [ ! -d $APP/$SERVER ]
then
echo "[mkdir: $APP/$SERVER]"
mkdir -p $APP/$SERVER
fi
echo "[create server: $APP.$SERVER ...]"
make cleanall -C /usr/local/haohao/demo/
cp /usr/local/haohao/demo/* $APP/$SERVER/
cd $APP/$SERVER/
SRC_FILE="DemoServer.h DemoServer.cpp DemoServantImp.h DemoServantImp.cpp DemoServant.jce makefile"
for FILE in $SRC_FILE
do
cat $FILE | sed "s/DemoServer/$SERVER/g" > $FILE.tmp
mv $FILE.tmp $FILE
cat $FILE | sed "s/DemoApp/$APP/g" > $FILE.tmp
mv $FILE.tmp $FILE
cat $FILE | sed "s/DemoServant/$SERVANT/g" > $FILE.tmp
mv $FILE.tmp $FILE
done
#rename "DemoServer" "$SERVER" $SRC_FILE
rename "s/DemoServer/$SERVER/" $SRC_FILE
#rename "DemoServant" "$SERVANT" $SRC_FILE
rename "s/DemoServant/$SERVANT/" $SRC_FILE
cd ../../
echo "[done.]"