diff --git a/Readme.md b/Readme.md index 222b4ee..5dca020 100644 --- a/Readme.md +++ b/Readme.md @@ -8,6 +8,7 @@ A command line program with shortcuts for managing hosts file entries. hosts add hosts remove hosts list [] + hosts show ( | | ) hosts edit hosts file diff --git a/hosts b/hosts index 5b29f9e..04f4617 100755 --- a/hosts +++ b/hosts @@ -694,15 +694,15 @@ file() { desc list <] Description: - List the existing IP / hostname pairs. When provided with the beginning of - an IP address, lists the pairs with matching IP addresses. + List the existing IP / hostname pairs. When provided with a seach string, all + matching lines will be printed. EOM list() { if [[ -n "$1" ]]; then - grep "^[^#]*$1" /etc/hosts + $_me show "$1" else # NOTE: use separate expressions since using a | for the or results in # inconsistent behavior. @@ -729,6 +729,24 @@ remove() { fi } +# ------------------------------------------------------------------------ show + +desc show < | | ) + +Description: + Print entries matching a given IP address, hostname, or search string. +EOM +show() { + if [[ -n "$1" ]]; then + grep "^[^#]*$1" /etc/hosts + else + $_me help show + exit 1 + fi +} + ############################################################################### # Run Program ###############################################################################