很高兴能分享我的对文件检查的SHELL:
#! /bin/bash
dir=/root
filelist="a.txt b.txt c.txt d.txt"
for file in $filelist
do
if [ ! -f $file ]
then
echo The file is not exited
else
echo Good,please notinue to do the next step
cp -p $file /root/temp/filestore
fi
done
#! /bin/bash
dir=/root
cd $dir
for file in test*
do
if [ ! -f $file ]
then
echo "The file is not exited"
exit 1
fi
cp $file /root/temp
echo $file is moved successfully!
done
if [ $? == 0 ]
then
echo success
else
echo failure
fi