1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-11-25 14:17:48 +00:00

Make list search terms match anywhere on the line

Making list more flexible enables searching for hostnames as well as
partial ip addresses.
This commit is contained in:
William Melody 2015-03-18 15:58:49 -07:00
parent a8461f48fd
commit cdf7793d7e
2 changed files with 2 additions and 2 deletions

View File

@ -7,7 +7,7 @@ A command line program with shortcuts for managing hosts file entries.
Usage:
hosts add <ip> <hostname>
hosts remove <hostname>
hosts list [127.]
hosts list [<search string>]
hosts edit
hosts file

2
hosts
View File

@ -702,7 +702,7 @@ Description:
EOM
list() {
if [[ -n "$1" ]]; then
grep "^$1" /etc/hosts
grep "^[^#]*$1" /etc/hosts
else
# NOTE: use separate expressions since using a | for the or results in
# inconsistent behavior.