Giter Site home page Giter Site logo

shell_script's Introduction

shell_script

shell脚本

mod_host.sh 传入替换文件的路径,会自动修改本机上/etc/hosts。做到了完美的去重和替换

使用方式

chmod +x mod_host.sh
./mod_host.sh <new_hosts path>

应用场景举例: 在容器中,new_hosts可以把宿主机的/etc/hosts mount进来,即指定宿主机的hosts,相当于复制一份宿主机的hosts列表,方便一些爬虫任务获取低延时的域名ip解析。

可以起一个定时任务,动态的修改容器hosts。

new_hosts的正则匹配模式可根据需要自行修改arrs=($(awk '/([0-9]{1,3}.){3}[0-9]{1,3}.#.[/ {print $1,$2}' $1))此行代码

备注: alpine使用的sh为busybox,不支持数组,需要使用bash自行安装apk add --no-cache bash bash-doc bash-completion

shell_script's People

Contributors

cjxhaaa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.