昨天朋友问怎么实现在shell,里面实现循环判断A文件是否存在,不存在的时候从别的目录拷贝文件
实现的思路很简单,首先实现判断文件是否存在,不存在的拷贝,然后价格死循环即可。
#!/bin/sh
myFile="/home/zexin/test/test.CIME"
# -f参数判断$myFile是否存在
while true #死循环
do
if [ ! -f "$myFile" ]; then
cp /home/zexin/save/test.CIME /home/zexin/test/
else
echo "file exits"
fi
done