mirror of
https://github.com/octoleo/hosts.git
synced 2024-11-25 06:07:40 +00:00
Add 'enabled' and 'disabled' options to list
These return records that have the status specified in the option.
This commit is contained in:
parent
9de0edda07
commit
7d8a94d4ca
@ -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 [<search string>]
|
||||
hosts list [enabled | disabled | <search string>]
|
||||
hosts show ( <ip> | <hostname> | <search string> )
|
||||
hosts disable ( <ip> | <hostname> | <search term> )
|
||||
hosts enable ( <ip> | <hostname> | <search term> )
|
||||
|
10
hosts
10
hosts
@ -743,7 +743,7 @@ file() {
|
||||
|
||||
desc list <<EOM
|
||||
Usage:
|
||||
$_me list [<search string>]
|
||||
$_me list [enabled | disabled | <search string>]
|
||||
|
||||
Description:
|
||||
List the existing IP / hostname pairs. When provided with a seach string, all
|
||||
@ -751,7 +751,13 @@ Description:
|
||||
EOM
|
||||
list() {
|
||||
if [[ -n "$1" ]]; then
|
||||
$_me show "$1"
|
||||
if [[ "$1" == disabled ]]; then
|
||||
sed -n "s/^\#disabled: \(.*\)$/\1/p" /etc/hosts
|
||||
elif [[ "$1" == enabled ]]; then
|
||||
grep -v -e '^$' -e '^\s*\#' /etc/hosts
|
||||
else
|
||||
$_me show "$1"
|
||||
fi
|
||||
else
|
||||
# NOTE: use separate expressions since using a | for the or results in
|
||||
# inconsistent behavior.
|
||||
|
Loading…
Reference in New Issue
Block a user