#!/bin/bash # byzhao # This is the basic bash script export LANG=zh_CN.UTF-8 request_log=/home/byzhao/github_hosts.log download_file=/etc/hosts.download
if [ -n "${start_num}" ] && [ -n "${end_num}" ]; then echo "解析文件行: ${start_num}, ${end_num}"
# 删除对应行 if sudo sed -i "${start_num},${end_num}d" /etc/hosts; then echo "删除原github hosts" else echo "删除原github hosts失败" exit 1 fi fi # 追加新的hosts到/etc/hosts if sudo sh -c "cat $download_file >> /etc/hosts"; then echo "追加新的hosts" else echo "追加新的hosts失败" exit 1 fi