aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/.local/bin/clean_local_ssh9
1 files changed, 6 insertions, 3 deletions
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