#本人新手写的不好之处,一定要指点我。我会不定期更新这个内容。
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"
时间: 2024-10-30 02:48:52