From cdf7793d7e7e7d9ba5e993da8beef12a09742788 Mon Sep 17 00:00:00 2001 From: William Melody Date: Wed, 18 Mar 2015 15:58:49 -0700 Subject: [PATCH] Make `list` search terms match anywhere on the line Making list more flexible enables searching for hostnames as well as partial ip addresses. --- Readme.md | 2 +- hosts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.md b/Readme.md index 90d41e4..222b4ee 100644 --- a/Readme.md +++ b/Readme.md @@ -7,7 +7,7 @@ A command line program with shortcuts for managing hosts file entries. Usage: hosts add hosts remove - hosts list [127.] + hosts list [] hosts edit hosts file diff --git a/hosts b/hosts index 1469184..5b29f9e 100755 --- a/hosts +++ b/hosts @@ -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.