码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本集合

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

标签:shell脚本集合

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

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脚本集合

标签:shell脚本集合

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!