参考:如何在shell脚本中使用goto语句 - VoidCC

效果:

 

注意修改以下几处:

show you my code:

#!/usr/bin/env bash # Define the choices to present to the user, which will be
# presented line by line, prefixed by a sequential number
# (E.g., '1) copy', ...)
target_eth='USB 10/100/1G/2.5G LAN'
choices=('ip for 192.168/24' 'ip for 10.71/24' 'show eth list' "get $target_eth info" 'exit')# Present the choices.
# The user chooses by entering the *number* before the desired choice. while [ "$menu" != 1 ]; do
printf "\nMain Menu:\n\n"
select choice in "${choices[@]}"; do # If an invalid number was chosen, $choice will be empty. # Report an error and prompt again. [[ -n $choice ]] || { echo "Invalid choice." >&2; continue; } # Examine the choice. # Note that it is the choice string itself, not its number # that is reported in $choice. case $choice in ip\ for\ 192.168/24) echo "Swithing..."networksetup -setmanual "$target_eth" 192.168.0.155 255.255.255.0 192.168.0.1 # Set flag here, or call function, ... echo "already changed. the new ip info is: " networksetup getinfo "$target_eth"break;;show\ eth\ list)networksetup -listnetworkserviceorder# Set flag here, or call function, ...break;; get\ $target_eth\ info)networksetup getinfo "$target_eth"break;;ip\ for\ 10.71/24) echo "Swithing..." networksetup -setmanual "$target_eth" 10.71.2.155 255.255.255.0 10.71.2.1     echo "already changed. the new ip info is: "networksetup getinfo "$target_eth" break;;exit)echo "Exiting now.."menu=1break;;*)echo "operation not avaliable!"break;;    esac # Getting here means that a valid choice was made, # so break out of the select statement and continue below, # if desired. # Note that without an explicit break (or exit) statement, # bash will continue to prompt. #break done
done
exit 0

Over.

MAC下切换多个IP的Shell脚本相关推荐

  1. linux脚本查看系统内存,二个linux下查看内存使用情况的shell脚本()

    摘要 腾兴网为您分享:二个linux下查看内存使用情况的shell脚本(),政务易,悦作业,优化大师,王者荣耀等软件知识,以及单向历app,优路教育app,kimoji,开关电源设计软件,皮皮高清影视 ...

  2. linux shell 设置ip,设置IP地址shell脚本

    #!/bin/bash A="IPADDR.*" B="NETMASK.*" C="GATEWAY.*" D="DNS1.*&qu ...

  3. 利用mac的launchd,开机后定时启动shell脚本

    利用mac的launchd开机后定时启动shell脚本 shell脚本 mac开机启动 概念 配置Mac开机后定时启动 参考文档 利用mac的launchd,开机后定时启动shell脚本 利用mac ...

  4. (原)Mac下Apache添加限制IP线程模块:mod_limitipconn.so

    1.下载:http://dominia.org/djao/limit/mod_limitipconn-0.24.tar.bz2 解压到一个目录:我的是~/Download/mod_limitipcon ...

  5. linux端口扫描脚本ip段,shell脚本结合iptables防端口扫描的实现

    网上有现在的防端口工具,如psad.portsentry,但觉得配置有点麻烦,且服务器不想再装一个额外的软件.所以自己就写了个shell脚本实现这个功能.基本思路是:使用iptables的recent ...

  6. bash 脚本_Bash技巧:可以左右下移动和旋转俄罗斯方块的Shell脚本

    在 Linux bash 中,之前文章介绍过使用 k.j.h.l 键来上下左右移动单个方块的 shell 脚本. 下面继续介绍如何旋转单个方块. 执行效果 具体的执行效果如下: 旋转前的截图 移动并旋 ...

  7. Linux 金字塔 的shell命令,linux下保留文件系统下剩余指定数目文件的shell脚本

    原文出处: http://www.jbxue.com/article/13808.html (原创文章,转载请注明出处) 本节内容: 保留文件系统下剩余指定数目的文件 例子: #!/bin/bash ...

  8. ubuntu下lvs负载均衡dr模型shell脚本

    架构图很简单如此这般: 关于lvs的介绍网上到处都是,这里不再赘述 直接上干货 dr上安装lvs管理工具 apt-get install ipvsadm linux 2.6.X内核默认集成了lvs模块 ...

  9. linux下开机自动启动,定时运行shell脚本

    Shell 脚本与window/dos 下的批处理相似,也就是用各类命令预先放入一个文件中,方便一次性执行的的一个程序文件,主要是方便管理员进行设置或者管理用. 一.shell脚本 在Linux下,我 ...

  10. 初级SHELL脚本(如何书写一个CentOS7的更改单网卡IP的shell脚本)

    问题描述: 目前公司项目现场使用的Centos7服务器越来越多,有的时候更改ip地址很麻烦,nmcli和nmtui命令对linux的新手来说很麻烦,所以写一个简单的shell脚本,让新人可以独立的更改 ...

最新文章

  1. SharePoint SiteCollection 和SubWeb之间的迁移
  2. (转)Http协议经典详解
  3. springmvc错误 Spring3.X jdk8 java.lang.IllegalArgumentException
  4. Python实现二叉树的遍历
  5. 县级外业调查及举证软件_省三调办举办全省第三次全国国土调查统一时点更新省级技术培训会...
  6. 汽车半导体器件AECQ认证测试及相关标准和表格文件
  7. 简述人工智能的发展历程图_人工智能发展简史
  8. toeic的学习网站
  9. Kubernetes Secrets
  10. openwrt 软路由负载均衡
  11. 电脑主板资料库 07【转至www.ongood.com.tw】【FreeXploiT收集整理】
  12. UE5/C++ 基于GAS创建攻击伤害 5.1.1准备碰撞体
  13. 计算机视觉博士去向,为什么现在不看好 CV 方向了呢?
  14. redis启动、关闭命令
  15. uniapp 电商app签到功能实现
  16. UltraEdit 15.10 注册码
  17. solaris IPMP
  18. 电商购物网站 - 数据库设计
  19. 世界各国的杀毒软件指引表
  20. 2021电赛F题之openmv巡线(附代码)

热门文章

  1. C++ opencv基于帧差法的关键帧提取
  2. js 实现图片上传
  3. java计算机毕业设计化妆品销售网站MyBatis+系统+LW文档+源码+调试部署
  4. cmd命令结束端口进程
  5. VoLTE信令泛读补充业务3:呼叫保持业务之保持流程
  6. PSnbsp;08人物抠图
  7. EasyUI整站示例系统-SyPro
  8. 纯css制作导航下拉菜单
  9. 应广单片机开发流程需要注意哪些?
  10. win10 jungo windriver