cmdhosts-file

How to remove custom string entries from a host files using cmd?


I've entered the following into the hosts file
127.0.0.1 www.facebook.com 127.0.0.2 www.youtube.com
how can I delete the above entries from the file using cmd?


Solution

  • An ugly solution:

    find /v "facebook" hosts | find /v "youtube" hosts > hosts
    

    /V Displays all lines NOT containing the specified string.


    see the documentation for find (ss64) system utility