标签: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脚本集合
原文地址:http://10856118.blog.51cto.com/10846118/1943506