#!/bin/bash
######Developed By - Krunal Patel(Linux Admin)#####
getent hosts $1 | grep $1
if [ $? == 0 ]; then
echo "hostname or ip address " {$1} " exists in /etc/hosts file"
else
read -p "please enter hostname to be added in /etc/hosts file : " hos
read -p "please enter ip address to be added in /etc/hosts file for $hos : " ipa
echo "$ipa $hos" >> /etc/hosts
fi
######Copyright © Krunal Patel (Shell Script Developer)######
No comments:
Post a Comment
Please give us suggestions.