Script to delete sudo access in redhat 5.4

Hi ,
This site is veryhelpful in resolving many issues.I have a request to delete sudo access for 3 users say user1,user2,user3 from around 50 servers in redhat 5.4.I know it is very time consuming to login to each server and delete entry in /etc/sudoers file.Is there any way can i do it using a script.
Appreicate your response on it.Advance thanks for your replies.

To get you started.

#!/bin/bash

server_list=(10.0.0.25)
regex="user1\|user2\|user3"

for((i=0; i< ${#server_list[@]}; i++))
do
    ssh root@${server_list[$i]} "sed  -i.bak \"/$regex/d\" /etc/sudoers"
done

Note : -i is included which will edit the file inline, which also creates a backup file. Once you confirm this works locally, then you can go ahead with full fledged.

HTH

Hi ahamed101 thansk for your reply.I have tried below script.after execution it deleted few other id's along with the mention 3 user id's.I have restored sudoers file again from the backup.

i think it is not taking user names from the list it seems.I have tried below script but it has given following result.

#!/bin/bash
server_list=(server1)
regex="sagbhat\|ralavudi\|bratinm"
for((i=0; i< ${#server_list[@]}; i++))
do
    ssh root@${server_list[$i]} "sed  -i.bak \"/$regex/d\" /etc/sudoers"
done

output:
It deleted few other id's

[root@server1 etc]# cat /etc/sudoers|grep kgough
[root@server1 etc]# cat /etc/sudoers|grep llewis
[root@server1 etc]# cat /etc/sudoers|grep bpadhi

appreciate your help on this.Thanks

Try with

regex="^user1\|^user2\|^user3"

Hi Tried with below option but no luck.It didn't work.

regex="^user1\|^user2\|^user3"