提取ip地址:
·
1 分钟阅读
·
Shell
[root@web41 ~]# ifconfig|grep “inet addr”|grep -o “[0-9.]{1,}“|head -n 1
192.168.70.41
[root@web41 ~]# ifconfig|grep “inet addr”|grep -o “[0-9.]{1,}“|sed -n 1p
192.168.70.41
:的用法
[root@web41 ~]# a="www.nana.com"
[root@web41 ~]# b=${a:4}
[root@web41 ~]# echo $b
nana.com
[root@web41 ~]# b=${a:6}
&
&
echo $b
na.com
可依此提取域名后面的内容:
web_domain=$1
proto_head=echo $domain|cut -d"." -f1
_length=expr length $proto_head #expr length计算字符长度
mail_domain=echo ${web_domain:$_length}
#shell-scripting
相关文章
-
#!/bin/bash PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin; export PATH function trafficmonitor { OSNAME=$(sed -n '1p' /etc/issue) eth=$1
Shell · 3 分钟阅读
-
转载 2017-09-30 作者:丁丁历险 的BLOG 我要评论 这篇文章主要介绍了Shell脚本生成随机密码的若干种可能,需要的朋友可以参考下 1.生成随机密码(urandom版本) < /dev/urandom tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 10
Shell · 3 分钟阅读
-
博客分类: Bash Shell shell 比较浮点数 由于程序需要,我要判断一个浮点数是否大于另一个浮点数。
Shell · 2 分钟阅读
-
#!/bin/bash while read line;do done < /tmp/conf.txt
Shell · 1 分钟阅读