您的位置:首页 > 其它

test_if.sh

2011-10-09 14:16 85 查看
test_if.sh

#!/bin/bash

logfile=if.logs

checkfile="mydir1 myfile1 lnmydir1 lnmyfile1 hello.sh hello"

echo "start" > ${logfile}

for tempFile in ${checkfile}

do

echo "checking ${tempFile} exist ..." >> ${logfile}

if [ -f ${tempFile} -o -d ${tempFile} -o -L ${tempFile} ] ; then

echo "rm -rf ${tempFile} ..." >> ${logfile}

rm -rf ${tempFile}

echo "rm -rf ${tempFile} OK!" >> ${logfile}

else

echo "the ${tempFile} not exist!" >> ${logfile}

fi

done

echo "begin mkdir mydir1 ..." >> ${logfile}

mkdir mydir1

echo "end mkdir mydir1 ok!" >> ${logfile}

echo "begin touch myfile1 ..." >> ${logfile}

touch myfile1

echo "end touch myfile1 ok!" >> ${logfile}

echo "begin ln -s mydir1 lnmydir1 ..." >> ${logfile}

ln -s mydir1 lnmydir1

echo "end ln -s mydir1 lnmydir1 ok!" >> ${logfile}

echo "begin ln -s myfile1 lnmyfile1 ..." >> ${logfile}

ln -s myfile1 lnmyfile1

echo "end ln -s myfile1 lnmyfile1 ok!" >> ${logfile}

echo "begin touch hello.sh ..." >> ${logfile}

touch hello.sh

echo "end touch hello.sh ok!" >> ${logfile}

chmod 777 hello.sh

echo '' >> hello.sh

echo 'echo "hello my shell world"' >> hello.sh

echo '' >> hello.sh

ln -s hello.sh hello

sleep 2

file mydir1 >> ${logfile}

file hello.sh >> ${logfile}

file hello >> ${logfile}

if test -d mydir1 -a -x hello.sh ; then

echo "in (if test -d mydir1 -a -x hello.sh) ..." >> ${logfile}

fi

echo "end!" >> ${logfile}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: