diff options
| author | la-ninpre <leobrekalini@gmail.com> | 2021-09-02 13:14:44 +0300 |
|---|---|---|
| committer | la-ninpre <leobrekalini@gmail.com> | 2021-09-02 13:14:44 +0300 |
| commit | 3961eb7bd8f412b12dfe229d93cf3f597f396989 (patch) | |
| tree | f523e6d160864b10547cdb32f055338b7a0217ad | |
| parent | cc9dfd76fa96d7caa821c661b9c526923f47e93f (diff) | |
| download | dotfiles-3961eb7bd8f412b12dfe229d93cf3f597f396989.tar.gz dotfiles-3961eb7bd8f412b12dfe229d93cf3f597f396989.zip | |
clean_local_ssh: fix behaviour
| -rwxr-xr-x | bin/.local/bin/clean_local_ssh | 9 |
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 |
