Tuesday, June 18, 2013

UNIX/Linux Shell Script to delete multiple users



Example 1:

To delete the users: dummy1, dummy2, dummy3, dummy4 and dummy5

for  counter in {1..5}; do userdel dummy$counter; done

It can also be written as,

for counter in {1..5}
 do 
       userdel dummy$counter
 done

NOTE: {1..5} syntax will not work in certain shell. But it will work definitely in bash.

Example 2:

cat > user.list
vijay
sanjay
ajay
sujay


for  user in `cat  user.list`;do userdel $user;done

1 comment:

Oracle Fusion said...

It is really very excellent; I find all articles were amazing. Awesome way to get more tips from everyone............... R12 Financials Online Training