#!/bin/bash if [ -f $1 ]; then source $1 fi uname | grep -q Linux LINUX=$? if [ "$LINUX" -eq "0" ]; then HOST=/etc/hosts else HOST=/cygdrive/c/Windows/System32/drivers/etc/hosts fi if [ ${HOSTNAMES[0]+1} ]; then for i in {0..99}; do if [ ${HOSTNAMES[$i]+1} ]; then XID="# Automated Host Def. Id. $i" if grep -q "$XID" $HOST; then REC=$( echo "s/.*$XID$/${HOSTNAMES[$i]}\ $XID/g" | sed "s/\ /\\\ /g" ) sed -i "$REC" $HOST else echo ${HOSTNAMES[$i]} $XID >> $HOST fi fi done fi