Skip to content

A BASH script that allows easy manipulation of the records in a hosts file, e.g. /etc/hosts

License

Notifications You must be signed in to change notification settings

martinbutt/hosts-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Hosts CLI

hostscli is a BASH script that allows easy manipulation of the records in a hosts file, e.g. /etc/hosts

Usage

Usage: hosts-cli {-D|-I|-R} -i <ip address> -h <hostname> [-f <filename>]

Actions:
  -D, --delete       Delete all matching records from the hosts file
                     If only IP or hostname is provided, all records matching will be deleted. If both are provided only an exact match is deleted.
  -I, --insert       Insert a new record into the hosts file.
  -R, --replace      Replace a host record in the hosts file with the new IP address.

Options:
  -i <ip_address>    The IP address of the record
  -h <hostname>      The hostname address of the record
  -f <filename>      The hosts file to operate on (defaults to /etc/hosts)

Examples

Inserting a new record

This command adds a new line to the hosts file

hosts-cli -I -i 1.1.1.1 -h one.x.io

Replacing an existing record

This command replaces a line in the hosts file

hosts-cli -R -i 2.2.2.2 -h one.x.io

Deleting an exact record

This command deletes a record that exactly matches this IP and hostname, e.g.

hosts-cli -D -i 1.1.1.1 -h one.x.io

Deleting all matching IP records

This command deletes all records that match an IP

hosts-cli -D -i 1.1.1.1

Deleting all matching hostname records

This command deletes all records that match a hostname

hosts-cli -D -h one.x.io 

About

A BASH script that allows easy manipulation of the records in a hosts file, e.g. /etc/hosts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages