Skip to content

Instantly share code, notes, and snippets.

@SuCicada
Created January 7, 2021 09:40
Show Gist options
  • Select an option

  • Save SuCicada/37b70ca48b463d97550f5689b96cf3d9 to your computer and use it in GitHub Desktop.

Select an option

Save SuCicada/37b70ca48b463d97550f5689b96cf3d9 to your computer and use it in GitHub Desktop.
hosts=/mnt/c/Windows/System32/drivers/etc/hosts
ip=`ifconfig eth0 | awk '/inet /{print substr($2,1)}'`
host=ubuntu.wsl2
if [ `grep -q $host $hosts` -gt 0 ];
sed -i '/$host/d' $hosts
fi
echo "$ip $host" >> hosts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment