1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-05-31 05:30:47 +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: Usage:
hosts add <ip> <hostname> hosts add <ip> <hostname>
hosts remove <hostname> hosts remove <hostname>
hosts list [127.] hosts list [<search string>]
hosts edit hosts edit
hosts file hosts file

2
hosts
View File

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