From 53f2f2c3ac03e8c3f67feeb527785d3184fac650 Mon Sep 17 00:00:00 2001 From: Vlad Doster Date: Fri, 10 Apr 2020 15:35:57 -0500 Subject: [PATCH] added comments --- .local/bin/delete_certain_known_hosts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.local/bin/delete_certain_known_hosts b/.local/bin/delete_certain_known_hosts index e009a490..fb545312 100755 --- a/.local/bin/delete_certain_known_hosts +++ b/.local/bin/delete_certain_known_hosts @@ -1,10 +1,14 @@ #!/bin/bash # Deletes certain lines of ~/.ssh/known_hosts + +# Check if any args passed if [ $# -eq 0 ]; then echo "Usage: ./delete_certain_known_hosts 3 5 7 23" echo "Will catch duplicate line numbers" exit 1 fi + +# Set loop variables known_hosts_path=~/.ssh/known_hosts lines_in_known_hosts=$(wc -l "$known_hosts_path" | awk '{print $1}') IFS=' ' @@ -18,6 +22,8 @@ else lines_to_delete+="${var}d;" fi done + +# Output information to user about what happened if [[ -z "$lines_to_delete" ]]; then echo "All arguments passed were invalid lines in $known_hosts_path" elif [[ -n "$string" ]]; then