|
我《在sed与awk》上抄的!
echo "editing $1"
if test "$1"=miao;then
echo "not editing sedscript!"
elif test -s $1;then
sed 's/shen/miao/g' $1>/tmp/$1$$
if test -s /tmp/$1$$
then
if cmp -s $1 /tmp/$1$$
then echo "file not changed."
else
mv $1 $1.bak
cp /tmp/$1$$
fi
echo "done"
else
echo "sed produce an empty file"
echo "-check your sedscript"
fi
else
echo "original file is empty"
fi
echo "all done"
运行 miao ss
结果:
editing ss
not editing sedscript!
all done
我的$1明明是 ss
怎么test "$1"=miao;还是为真; |
|