首页 > 系统服务 > 详细

shell脚本集合

时间:2017-06-30 17:02:06      阅读:234      评论:0      收藏:0      [点我收藏+]

#本人新手写的不好之处,一定要指点我。我会不定期更新这个内容。

1、输入IP地址查找/etc/hosts文件中指定的域名

#!/bin/sh
#author vperson
#qq 737304790
#Enter the specified IP to find the corresponding domain name in the hosts file

flag=0

if [ $# -ne 1 ]
	then
	echo "Input error"
	echo "Usage: $0 127.0.0.1"
	exit 1
fi

exec < /etc/hosts

while read line
do
	if [ "$1" = "`echo $line|awk ‘{print $1}‘`" ]
		then
			flag=1
			printf "Successfully find the domain name!\n"
			echo -e "\033[31m $1==>> `echo $line|awk ‘{print $2}‘` \033[0m"
			break
	fi
done

[ ${flag} -eq 0 ] && echo "No specified IP"




本文出自 “10846118” 博客,请务必保留此出处http://10856118.blog.51cto.com/10846118/1943506

shell脚本集合

原文:http://10856118.blog.51cto.com/10846118/1943506

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!