Shell脚本中获取本机ip地址的3个方法
来源:互联网 发布:java 解析swf 编辑:程序博客网 时间:2024/06/07 03:23
这篇文章主要介绍了Shell脚本中获取本机ip地址的3个方法,本文直接给出实现代码,需要的朋友可以参考下
方法一:
复制代码代码如下:
/sbin/ifconfig -a|grep inet|grep -v 127.0.0.1|grep -v inet6|awk '{print $2}'|tr -d "addr:"
or
/sbin/ifconfig|sed -n '/inet addr/s/^[^:]*:\([0-9.]\{7,15\}\) .*/\1/p'
方法二:
复制代码代码如下:
local_host="`hostname --fqdn`"
local_ip=`host $local_host 2>/dev/null | awk '{print $NF}'`
方法三:
复制代码代码如下:
local_host="`hostname --fqdn`"
nslookup -sil $local_host 2>/dev/null | grep Address: | sed '1d' | sed 's/Address://g'
阅读全文
0 0
- Shell脚本中获取本机ip地址的3个方法
- Shell脚本中获取本机ip地址的3个方法
- Linux Shell脚本中获取本机ip地址方法
- Linux Shell脚本中获取本机ip地址方法
- shell中获取本机ip地址
- shell中获取本机ip地址
- 获取本机IP地址的脚本
- C#中获取本机IP地址的方法
- 获取本机IP地址的方法:
- shell 脚本获取本地ip地址方法
- linux shell获取本机ip地址
- Android开发中获取本机Mac地址和IP地址的方法
- 简单的获取本机ip地址的方法
- 获取外网本机的IP地址的方法
- java获取本机ip地址方法
- socket获取本机IP地址方法
- Java获取本机IP地址方法。
- 获取本机所有IP地址的方法
- 台湾大学机器学习基石lecture1小结
- 38. Count and Say
- ajax跨域,以及在laravel中实现跨域
- ArrayList的学习笔记
- JQuery实现注册表单页面 4 代码
- Shell脚本中获取本机ip地址的3个方法
- usaco-4.2.2The Perfect Stall完美的牛栏
- 面向对象——封装性
- Codeforces Similar Words [trie树+树形dp]
- 虚拟路径配置
- POJ 2385 Apple Catching
- 排序
- 【初识博客】IT之路的flag
- Eclipse环境安装Python插件PyDev及开发步骤