Pages

Saturday, April 16, 2016

Get Hostname associated with ip address from /etc/hosts file


You need to add command line argument as mentioned in screenshot.



#!/bin/bash
#Developed By - Krunal Patel ( Linux Admin)
cat /etc/hosts | grep $1 | awk {'print $2,$3'}

No comments:

Post a Comment

Please give us suggestions.

Shell Script Code