以下贴出示例脚本:

#!/system/bin/sh

filePath="/data/etc/hosts"
TAG="copyhost"                                                                                                         
echo "start copyhost"                                                                                                  
log -t "$TAG" "begin copyhost"  log -t 日志打印

if [ ! -f "$filePath" ]; then
	log -t "$TAG" "$filePath not exit"
	echo "文件不存在:$file"
	echo "127.0.0.1       localhost" >$filePath
	echo "::1             ip6-localhost" >> $filePath
	echo "127.0.0.1       hostname" >> $filePath
else
    echo "文件存在:$file"
	log -t "$TAG" "$filePath exit"
fi

更多推荐