diff --git a/.local/bin/delete_certain_known_hosts b/.local/bin/delete_certain_known_hosts index a3d13a4e..e009a490 100755 --- a/.local/bin/delete_certain_known_hosts +++ b/.local/bin/delete_certain_known_hosts @@ -13,10 +13,15 @@ read -r -a delete_these_lines <<< "$deduped_args" lines_to_delete="" for var in "${delete_these_lines[@]}"; do if [[ "$var" -gt "$lines_in_known_hosts" ]]; then - echo "$var isnt valid line in $lines_in_known_hosts line $known_hosts_path" + echo "$var is invalid line in $lines_in_known_hosts line $known_hosts_path" else lines_to_delete+="${var}d;" fi done -sed -i "$lines_to_delete" "$known_hosts_path" -echo "Deleted lines $(echo $(echo $lines_to_delete | sed 's/d;/, /g') | sed 's/.$//' )" +if [[ -z "$lines_to_delete" ]]; then + echo "All arguments passed were invalid lines in $known_hosts_path" +elif [[ -n "$string" ]]; then + sed -i "$lines_to_delete" "$known_hosts_path" + echo "Deleted lines $(echo $(echo $lines_to_delete | sed 's/d;/, /g') | sed 's/.$//' )" +fi +