From 3961eb7bd8f412b12dfe229d93cf3f597f396989 Mon Sep 17 00:00:00 2001 From: la-ninpre Date: Thu, 2 Sep 2021 13:14:44 +0300 Subject: clean_local_ssh: fix behaviour --- bin/.local/bin/clean_local_ssh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/.local/bin/clean_local_ssh b/bin/.local/bin/clean_local_ssh index 54b67a9..45fafce 100755 --- a/bin/.local/bin/clean_local_ssh +++ b/bin/.local/bin/clean_local_ssh @@ -2,14 +2,17 @@ _known_hosts="$HOME/.ssh/known_hosts" -grep localhost "$_known_hosts" +grep localhost "$_known_hosts" || { + echo "no localhost entries" && exit 0 +} printf "remove these entries? [y/N] " read -r REMOVE case "$REMOVE" in - [Y|y]) - grep -v localhost "$_known_hosts" | tee "$_known_hosts.new" + [Yy]) + grep -v localhost "$_known_hosts" > "$_known_hosts.new" mv "$_known_hosts.new" "$_known_hosts" + exit 0 ;; *) exit 1 -- cgit v1.2.3