Hi All,
I am reading the host file by ignoring the comments and write it to the other file. I am reading with regular expression for IP address.
grep -E '^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' $inputFile | awk '{for(i=2;i<=NF;i++)print $1,$i}' > $DR_HOME/OS/temp
After that am reading each host name and pinging it and matching the IP address in the response with the IP address in the file.
while read ip host
do
ip1=$(ping -q -c 1 -W 1 "$host" |grep PING | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}')
Now my host file contains the comment at the end of the line also For E.G.
10.3.200.51 SQL1 SQL1.com Delta Delta.com ori ori.com #TIB Prod
How to ignore the comments in the end while reading the line