we want to add some function as rm function to bashrc , and after some configuration to remove the function rm
so first the following described the approach how to add the function rm to bashrc
echo '
function rm
{
echo "ERROR rm command not allowed on this machine"
return 1
}
' >>/root/.bashrc
and then reload
source /root/.bashrc
in some stage in our scripts we need to do the opposite approach - delete the function rm
function rm
{
echo "ERROR rm command not allowed on this machine"
return 1
}
so I create the following sed
sed -i '1,/function/p;/}/,$p' /root/.bashrc
but I not so feel good with above approach - deletion the function
I will appreciate to get better approach to delete the function rm, from /root/.nashrc