首页 > 编程知识 正文

hosts修改器,switch科学访问

时间:2023-05-05 05:16:28 阅读:160750 作者:2949

本人的Ubuntu20.04环境交换机主机无法切换,可能是程序错误,正在着急使用,所以写了脚本

() /紧凑型百合下mkdir -p ~/) /紧凑型百合/host list echo ' export path=$ path : $ home /紧凑型百合(/. bash _ profiles 备用系统hostscat /etc/hosts ~/紧凑型百合/host list/system.hosts.txt vim~/紧凑型百合/chhost#! /usr/紧凑型百合/bash#function changeHost () scriptdir=$(CD$(dirname$0) ); pwd ) echo ' switch to $1hosts . ' path host=$ script dir '/host list ' file=$ path host '/' $1'.hosts.txt ' if [! -f '$file' ] ' '; then echo 'file not exits! 3360 $ file ' echo ' ' echo ' includethishosts 3360 ' hosts=`/usr /紧凑型百合/ls $pathhost | /usr/紧凑型百合/sed's/. hosts echo $ hosts ls $ pathhhostecho ' ' exitfisystemfile=$ path host '/system.hosts.txt ' tmpfile=$ path host ' tmp . cat $file $tmpfile /usr/紧凑型百合/sudo /usr/紧凑型百合/CP $ tmpfile/etc/hosts echo ' } change host $1() /紧凑型百合

您可以切换到xxx.hosts.txt环境

xxx.hosts.txt文件格式与/etc/hosts文件格式相同

使用示例my编辑my.hosts.txt :

~~小巧的百合/hostslist/my.hosts.txt

# startmyhosts 199.232.68.133 raw.github user content.com 151.101.76.133 raw.github user content.com # endmyhoststsccom

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。