From 514f6c0a32d3a7cac174377eb6a5e6e69900a3e1 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Thu, 17 Mar 2016 10:40:53 -0500 Subject: [PATCH] Add knownrm function for deleting a line from known_hosts file. --- .bash_profile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.bash_profile b/.bash_profile index 26eecd2..4d764ba 100644 --- a/.bash_profile +++ b/.bash_profile @@ -76,6 +76,16 @@ export ANSIBLE_NOCOWS=1 alias an='ansible' alias ap='ansible-playbook' +# Delete a given line number in the known_hosts file. +knownrm() { + re='^[0-9]+$' + if ! [[ $1 =~ $re ]] ; then + echo "error: line number missing" >&2; + else + sed -i '' "$1d" ~/.ssh/known_hosts + fi +} + # Ask for confirmation when 'prod' is in a command string. prod_command_trap () { if [[ $BASH_COMMAND == *prod* ]]